简体   繁体   English

Mac OS X中是否有相当于mallopt()的功能?

[英]Is there an equivalent of mallopt() in Mac OS X?

Linux offers customization options for memory allocation via mallopt() . Linux通过mallopt()提供了用于内存分配的自定义选项。 Are there similar options for customizing memory allocation on OS X (BSD)? 是否有类似的选项可用于自定义OS X(BSD)上的内存分配?

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. OS X曾经包含mallopt()函数,尽管现在它释放内存的方式与过去不同,因此您需要在10.7及更高版本中找到替代方法。 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: 尽管您可以在以下标头中找到大多数等效的功能,但您mallopt()要查找哪种类型的特定mallopt()内存分配选项:

/usr/include/malloc/malloc.h
/usr/include/mach/vm_map.h

Functions that you might find similar in functionality to mallopts() : 您可能会发现与mallopts()类似的功能:

malloc_zone_pressure_relief() 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 (ie munmap()-ing) "goal" bytes from "zone". 建议malloc子系统该进程处于内存压力下,并且子系统应尽最大努力从“ zone”释放(即munmap()-ing)“目标”字节。 If "goal" is passed as zero, the malloc subsystem will attempt to achieve maximal pressure relief in "zone". 如果将“目标”传递为零,则malloc子系统将尝试在“区域”中实现最大压力释放。 If "zone" is passed as NULL, all zones are examined for pressure relief opportunities. 如果将“ zone”设置为NULL,则检查所有区域的泄压机会。 malloc_zone_pressure_relief() returns the number of bytes released. malloc_zone_pressure_relief()返回释放的字节数。

vm_allocate() 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 ↳OS X内存使用性能准则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM