I really do hate to pile on with negative comments, but there are several at best misunderstandings and at worst errors in this:
1. TFA argues that malloc is for dynamic memory allocation and that arrays are for fixed counts. Sort of. In modern C, you can always char someArray[someValue]; what you cannot do is char someArray[someValue] = { '\0' }; making malloc good for the case where you need some initialization, but then you should probably be using calloc or some other call.
2. TFA indicates that top will tell you how much memory your process is using. Uh, sorta kinda maybe not always? Reporting memory utilization is a black art, top was built before current opacity, and this area is never as clear and clean as it seems. I have a tab group called "true memory usage" which consists of a dozen or more pages to remind how many edge cases there are here. hic sunt draconis
3. TFA kinda sorta implies that malloc means a system call and a change to brk, but TFA also mentions that malloc isn't a system call but a libc call: if you have previously called malloc and freed memory, or if your task's space is large enough, malloc might not involve a system call at all and brk/srbk might not be involved, since libc may have satisified your memory request from your existing task space.
It reads like a fine, clear, and correct article, but it isn't, really. Sad to say, because it did read really well.
2 comments
[ 4.8 ms ] story [ 25.4 ms ] thread1. TFA argues that malloc is for dynamic memory allocation and that arrays are for fixed counts. Sort of. In modern C, you can always char someArray[someValue]; what you cannot do is char someArray[someValue] = { '\0' }; making malloc good for the case where you need some initialization, but then you should probably be using calloc or some other call.
2. TFA indicates that top will tell you how much memory your process is using. Uh, sorta kinda maybe not always? Reporting memory utilization is a black art, top was built before current opacity, and this area is never as clear and clean as it seems. I have a tab group called "true memory usage" which consists of a dozen or more pages to remind how many edge cases there are here. hic sunt draconis
3. TFA kinda sorta implies that malloc means a system call and a change to brk, but TFA also mentions that malloc isn't a system call but a libc call: if you have previously called malloc and freed memory, or if your task's space is large enough, malloc might not involve a system call at all and brk/srbk might not be involved, since libc may have satisified your memory request from your existing task space.
It reads like a fine, clear, and correct article, but it isn't, really. Sad to say, because it did read really well.