alloc_hugepages - Linux


alloc_hugepages is a command-line utility used to allocate huge pages in the memory of a Linux system. Huge pages are larger than the standard page size (typically 4KB) and can improve performance for applications that handle large amounts of data by reducing Translation Lookaside Buffer (TLB) misses and improving memory bandwidth utilization.


alloc_hugepages [options] number_of_pages [page_size_in_kb]


  • -g, –gid: Sets the group ID of the allocated huge pages. Default is the effective group ID of the current user.
  • -m, –mode: Sets the file permissions of the allocated huge pages. Default is 0666.
  • -p, –prefix: Specifies the prefix of the file name used to create the huge page file. Default is "hugepages".
  • -r, –remove: Removes the specified number of huge pages.
  • -s, –size: Specifies the size of the huge pages in kilobytes. Default is 2048 (2MB).
  • -t, –type: Specifies the type of huge pages to allocate. Can be "default", "2MB", "1GB", or "16GB". Default is "default".
  • -uid: Sets the user ID of the allocated huge pages. Default is the effective user ID of the current user.


Allocate 1024 2MB huge pages:

alloc_hugepages 1024 2048

Allocate 512 1GB huge pages:

alloc_hugepages 512 1024

Remove 256 2MB huge pages:

alloc_hugepages -r 256 2048

Common Issues

  • Insufficient memory: If the system does not have enough free memory, the allocation will fail.
  • Permission denied: Make sure you have sufficient privileges to create files in the specified directory.
  • Huge pages not supported: Some systems may not support huge pages. Check your kernel configuration or consult the system documentation.


Combined with vmstat: Monitor huge page usage in real-time:

vmstat 1 | grep -i huge

Related Commands

  • hugeadm: Manages huge pages and huge page size settings.
  • numastat: Shows memory utilization on different NUMA nodes.
  • dmesg: Displays kernel messages related to huge page allocation.