I have a mutlithreaded linux server (64 bit) which is supposed to run and handle the requests for days. But for some time now I am seeing sudden jump in the memory utilization of the process. Sometimes this comes down after some time but sometimes my process is crashed after it reaches the threshold limit.
I used the smaps and pmap to find out the mappings and found that the heap size was 390 MB whereas the total memory utilization at that time was 4.5GB.
I could see a lot of anon memory segments in the pmaps output so I ran the strace and found that at the time of memery jump my process was calling mmap with 134MB size:
29045 19:52:45 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2aabf8000000
29045 19:53:12 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2aac00000000
29045 19:53:21 mmap(0x2aac04000000, 67108864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2aac04000000
29045 19:53:28 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2aac08000000
I wrote my wrapper for malloc and found that the maximum memory allocation done by my application was One 30MB allocation and one 20MB allocation at the time of jump. And this memory was freed.
I need to know why my process is calling these big mmaps?
Additional Information:
I breaked at mmap and found following BT:
#0 0x00000032af6d0940 in mmap64 () from /lib64/libc.so.6
#1 0x00000032af66f9cf in new_heap () from /lib64/libc.so.6
#2 0x00000032af673515 in _int_malloc () from /lib64/libc.so.6
#3 0x00000032af674cde in malloc () from /lib64/libc.so.6
The malloc was called with 5060 bytes but mmap was called with size 134217728. Why malloc is calling new_heap()?