maiko
maiko copied to clipboard
Use mmap() in place of posix_memalign() to allocate Lisp memory
posix_memalign() does not guarantee initializing the allocated memory to zero, which Lisp expects, so the code must memset() the entire allocated region to zero. The effect of this is (generally) to force the allocation of RAM to the process, which is wasteful, since we normally start with only 4% of 256 MB in use for a full.sysout. Allocating memory with mmap, using MAP_ANON, guarantees that the memory is already zeroed (effectively mapping /dev/zero with copy-on-write) so it is not necessary to touch it before use. This keeps the pre-allocated RAM to a minimum.