How To check if Transparent Huge Pages are enabled
Transparent Huge Pages (THP), also known as Anonymous Huge Pages, are an important optimisation for linux memory management in machines with large amounts of RAM. While this optimisation makes short-lived applications much faster (transcoding, streaming), it interferes with long-running dynamic applications, such as Aerospike. Applications using JEMalloc are specifically affected and their ability to account for, and effectively manage, memory is severely impacted. This may present itself and look like a memory leak.
When running Aerospike, THP must be disabled. To check whether THP is enabled, see
$ cat /proc/meminfo ... AnonHugePages: 43046912 kB CmaTotal: 0 kB CmaFree: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB
On newer kernels, the line
AnonHugePages: 43046912 kB represents how many transparent huge pages have been allocated. Some THP may be allocated during boot, before Aerospike starts. This should amount to only a few pages (of default size 2mB). If this turns out to be a large number, THP is still enabled after boot and Aerospike cannot properly account its memory. In this example, 41 gB was allocated as THP. That’s 21019 pages at 2 mB each. Aerospike will be unable to account for some of those pages during its operation.
To disable THP, please follow the Disabling THP article.
To release transparent huge pages, simply disabling said pages and restarting Aerospike may not help. After configuring THP to disable on reboot, as per the article, it is best to perform the system reboot to ensure all anonymous pages have been cleared.
THP ENABLED MEMINFO TRANSPARENT HUGE PAGES ANONHUGEPAGES