Reputation: 96947
Linux offers customization options for memory allocation via mallopt()
. Are there similar options for customizing memory allocation on OS X (BSD)?
Upvotes: 1
Views: 574
Reputation: 47169
OS X used to include the mallopt()
function, although now it releases memory differently than in the past, so you'll need to find an alternative in versions 10.7 and above. It's unclear what type of specific mallopt()
memory allocation options you're looking for, although most of the equivalent functions would be found in the following headers:
/usr/include/malloc/malloc.h
/usr/include/mach/vm_map.h
Functions that you might find similar in functionality to mallopts()
:
malloc_zone_pressure_relief()
advises the malloc subsystem that the process is under memory pressure and that the subsystem should make its best effort towards releasing (i.e. munmap()-ing) "goal" bytes from "zone". If "goal" is passed as zero, the malloc subsystem will attempt to achieve maximal pressure relief in "zone". If "zone" is passed as NULL, all zones are examined for pressure relief opportunities. malloc_zone_pressure_relief() returns the number of bytes released.
vm_allocate()
allocates a region of virtual memory in the specified task's address space. A new region is always zero filled.
↳ OS X Memory Usage Performance Guidelines
Upvotes: 1