News for hackers. Stuff that matters.
Re:A quick tutorial on implementing C memory management func... by duaneb on Friday December 05, 2014 @04:07PM (#8706902)
> Second, I wonder if it would make sense to jump straight to using mmap() instead of the classic brk()/sbrk().

Yes, it will. brk/sbrk are terrible ways to allocate anything but more stack. Use mmap instead, both for more control over the layout in memory, and for more portability.

Re:A quick tutorial on implementing C memory management func... by nkurz on Friday December 05, 2014 @04:46PM (#8707105)
Perhaps you know: on Linux, how do mmap() and brk() differ as far as page initialization? Does brk() conceptually include the effects of MAP_POPULATE? Do both of them cause virtual to physical memory mapping at the time of the call?
Re:A quick tutorial on implementing C memory management func... by duaneb on Friday December 05, 2014 @04:50PM (#8707123)
I'm not sure as to the specifics, because brk is a strict subset of mmap; however, I would be surprised if it doesn't use the full VM substructure to allocate the mapping immediately.

I would amend my statement before to say that, if you're looking into memory allocation, conceptually, mmap is where everything happens these days. brk is kept for backwards compatibility.

Re:A quick tutorial on implementing C memory management func... by lgeek on Saturday December 06, 2014 @09:35AM (#8709276)
On the systems I've seen, brk makes a lazy allocation, i.e. it doesn't allocate physical memory until you write to a page.