My application frees up a huge chunk of memory on receiving a particular event. Here is the mallinfo stats before the event. 2015-05-08 19:39:28,453 INFO sas2 - Total non-mmapped bytes (arena): 181747712 2015-05-08 19:39:28,453 INFO sas2 - # of free chunks (ordblks): 14340 2015-05-08 19:39:28,453 INFO sas2 - # of free fastbin blocks (smblks): 17 2015-05-08 19:39:28,453 INFO sas2 - # of mapped regions (hblks): 36 2015-05-08 19:39:28,453 INFO sas2 - Bytes in mapped regions (hblkhd): 139460608 2015-05-08 19:39:28,453 INFO sas2 - Max. total allocated space (usmblks): 0 2015-05-08 19:39:28,453 INFO sas2 - Free bytes held in fastbins (fsmblks): 912 2015-05-08 19:39:28,453 INFO sas2 - Total allocated space (uordblks): 175712192 2015-05-08 19:39:28,453 INFO sas2 - Total free space (fordblks): 6035520 2015-05-08 19:39:28,453 INFO sas2 - Topmost releasable block (keepcost): 60112
The stats after processing the event are 2015-05-08 19:40:44,696 INFO sas2 - Total non-mmapped bytes (arena): 181747712 2015-05-08 19:40:44,696 INFO sas2 - # of free chunks (ordblks): 797 2015-05-08 19:40:44,696 INFO sas2 - # of free fastbin blocks (smblks): 0 2015-05-08 19:40:44,696 INFO sas2 - # of mapped regions (hblks): 38 2015-05-08 19:40:44,696 INFO sas2 - Bytes in mapped regions (hblkhd): 153735168 2015-05-08 19:40:44,696 INFO sas2 - Max. total allocated space (usmblks): 0 2015-05-08 19:40:44,696 INFO sas2 - Free bytes held in fastbins (fsmblks): 0 2015-05-08 19:40:44,696 INFO sas2 - Total allocated space (uordblks): 1056528 2015-05-08 19:40:44,696 INFO sas2 - Total free space (fordblks): 180691184 2015-05-08 19:40:44,696 INFO sas2 - Topmost releasable block (keepcost): 238368 As you can see, there is almost 180MB of free memory indicated by fordblks. Although the application frees up the memory, malloc doesn't seem to give it back to kernel. Since my system is already memory constrained, I cannot afford to lose such a huge chunk of memory. Is there a way I can forcefully free the bytes indicated by fordblks?
I tried malloc_trim and it didn't help. As you can see, it just frees the "keepcost" bytes.
Aucun commentaire:
Enregistrer un commentaire