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?
If you follow the instruction below, you can get rid of the allocated hugepages:
1) Let's check the hugepages which were free at restart
2) Starting a dpdk application with wrong parameters, producing an error
3) When I check hugepages, there is not any free
4) Now, when I check the mounted hugepage directory, I can see the files which are not given back to OS by dpdk application.
5) Finally, if you remove the files starting with rtemap, you can give the hugepages back
Use 'ipcs -m' to list the shared memory segments. Use 'ipcrm' to remove the left over shared memory segments.
Hope that helps....
HugeTLB can either be used for shared memory (and Mark J. Bobak's answer would deal with that) or the app mmaps files created in a hugetlb filesystem. If the app crashes without removing those files they survive and keep corresponding memory 'allocated'.
Check hugeTLB filesystem and see if there are any leftover files from the app. Removing them would release the memory.
your hugetlb may be used by shared memory or mmap files. try to remove the shared memories or umount the hugetlb fs
Sometimes need to check all directory that hugetlbfs has been mounted. So,
find mounted directory by command
mount | grep huge
.check every directory except especially
/dev/hugepages
.delete all 2M-sized files. (2M is the size of hugepage)