How to Release Hugepages from the Crashed Application

How to release hugepages from the crashed application

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.

Proper Way to Release a Hugepage?

To delete files you need to unmap all mappings, close all file descriptors, and unlink all names.

You need to call unlink() on the file.

c++ application fails allocating more hugepages than a certain limit


However the application crashes with a std::bad_alloc exception at 128G allocated (or 65536 pages).

You are allocating too many small-sized segments, there is a limit of the number of map segments you can get per process.

sysctl -n vm.max_map_count

You are trying to use 1024 * 512 * 4 == 2097152 MAP at least and one more for the array, but the default value of vm.max_map_count is only 65536.

You can change it with:

sysctl -w vm.max_map_count=3000000

Or you could allocate a bigger segment in your code.

No free hugepages reported in hugepages when running DPDK helloworld example


1. 1GB Hugepages

The example complains about 1048576kB hugepages, i.e. 1GB. This is correct, you don't have 1GB pages configured as we can see in /proc/meminfo

But you do not need 1GB pages to start a DPDK application, so it just informs and continues.

2. Free Hugepages

The free hugepages are all gone because if we do not specify the amount of memory to use for the DPDK application with -mor --socket-mem option, it will reserve all the available hugepages.

More on that in DPDK Getting Started Guide here.

In case the hugepages remain allocated even when the application has ended (or crashed), you can free the hugepages manually by removing files in /mnt/huge



Related Topics



Leave a reply



Submit