问题
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