Re: zero-fill and memory allocation size
Re: zero-fill and memory allocation size
- Subject: Re: zero-fill and memory allocation size
- From: Eric Gouriou <email@hidden>
- Date: Thu, 10 Dec 2009 14:38:16 -0800
On Dec 10, 2009, at 11:43 AM, Joel Reymont wrote:
> I understand that allocations over a certain size come from the virtual memory manager and have to be zero-filled. Is 15K still that size?
Define "still".
In SnowLeopard the limit for "large" allocations was raised to 127kB
for systems containing more than 1GB of physical memory. The limit
remains 15kB for 1GB systems, the minimum memory size specified
at <http://www.apple.com/macosx/specs.html>.
Note however that SnowLeopard also introduced a "death row" optimization
for large allocations. A limited amount of freed large allocations does stick around.
This means that large allocations can often be satisfied without invoking a system call.
One side-effect of this optimization is that those allocations will not always be zero-filled,
unless calloc() is being used. This was never guaranteed previously but was a side-effect
of large allocations being serviced via vm_allocate() (< 10.5) or anonymous mmap() (>= 10.5).
I believe that, for compatibility purposes, zero-filling is still performed for applications
linked with a target version early than SnowLeopard.
The details can be found in the Libc sources:
<http://www.opensource.apple.com/source/Libc/Libc-583/gen/magazine_malloc.c>
Eric
> Thanks, Joel
>
> ---
> Mac hacker with a performance bent
> http://www.linkedin.com/in/joelreymont
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden