Dan Sugalski wrote:

[ zerofilled aligned memory ]


That, as much as anything, argues for an entry in platform.c to get and return large sections of memory. I know it's reasonably doable on a lot of platforms, just potentially differently everywhere.


BTW the zero filled memory is not that important. When we put the objects onto the free list or take them off it, we are touching their memory. In the latter case the object will be used thereafter, so that's the point to wash the memory.

More important is the proper alignment of the blocks. But if we get zeroed memory for free, we can save some extra cycles too.


$ man memalign
No manual entry for memalign


Yeah, it seems depressingly rare.


linux/drivers/char/mem.c and malloc.c:


#define MMAP(addr, size, prot, flags) ((dev_zero_fd < 0) ? \
(dev_zero_fd = open("/dev/zero", O_RDWR), \
mmap((addr), (size), (prot), (flags), dev_zero_fd, 0)) : \
mmap((addr), (size), (prot), (flags), dev_zero_fd, 0))


and:

/*
  Standard unix mmap using /dev/zero clears memory so calloc doesn't
  need to.
*/

That's it
leo



Reply via email to