How to release hugepages from the crashed application

jaeyong picture jaeyong · Dec 4, 2013 · Viewed 16.7k times · Source

I have an application that uses hugepage and the application suddenly crashed due to some bug. After crashing, since the application does not release the hugepage properly, the free hugepage number is not increased in sys filesystem.

$ sudo cat /sys/kernel/mm/hugepages/hugepages-2048kB/free_hugepages 
0
$ sudo cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages 
1024

Is there a way to release the hugepages by force?

Answer

ptan picture ptan · Oct 21, 2014

Sometimes need to check all directory that hugetlbfs has been mounted. So,

  1. find mounted directory by command mount | grep huge.

  2. check every directory except especially /dev/hugepages.

  3. delete all 2M-sized files. (2M is the size of hugepage)