AIX process memory is increasing with malloc free calls in loop

烂漫一生 提交于 2019-12-10 17:46:35

问题


I am running this code on AIX 6.1

while(true)
{
    int a = rand(); //generate a random integer value
    void* test = malloc(a*a); //allocate large chunk of memory block
    usleep(3000000); //sleep for 3 sec 
    free(test); // release memory block
}

using MALLOCTYPE=buckets My observation is Resident set size(real memory) and data section size for process is continuously increasing. This is check by command ps v PID pg sp value shown in topas for process is slowly increasing.

Can someone justify this behavior.


回答1:


On free, memory is not released to AIX os, but it is reserved for reuse. With MALLOCOPTIONS=disclaim, free releases memory back to AIX os and their is not increase in memory utilization. But with MALLOCOPTIONS=disclaim, CPU utilization is almost 2-3 times greater.



来源:https://stackoverflow.com/questions/13294552/aix-process-memory-is-increasing-with-malloc-free-calls-in-loop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!