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 -m
or --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
One Liner to Rename Bunch of Files
Command for Finding Process Using Too Much Cpu
How to Flush Cache of Hard-Disk and Flash-Disk (Or Filesystem) from Command Line
Newbie on Debian and Trying to Make Java 7 the Default Java Version Used
Assigning Output of a Command to a Variable(Bash)
Linux X86-64 Assembly and Printf
Get the Characters After the Last Index of a Substring from a String
Vim: Access to System Clipboard via Ssh - Linux to Os X
How to Print Message to Stderr in Go
Best Way to Overwrite File with Itself
Is There a Clang Mingw Cross Compiler for Linux
Shell Script Password Security of Command-Line Parameters
/Tmp VS. /Dev/Shm for Temp File Storage on Linux
Converting HTML to Odt, Doc, Docx
How to Disassemble Raw Mips Code
How to Rename Files in Bash to Increase Number in Name