JVM large pages support: is memory wasted if large pages is larger than heap?

1.6k views Asked by At

I just found a JVM configuration, where the size of the configured large pages is much bigger than the allocated heap size for the JVM.

The configuration I added below is for a Websphere Application Server, but the problem would be the same for any other Java application that is using large pages. In general large pages are enabled for IBM JRE using -Xlp (IBM Knowledge Center- Tuning Linux systems) switch and for Oracle using -XX:+UseLargePages (Oracle: Java Support for Large Memory Pages)

The current configuration shows

vm.nr_hugepages = 4096 
Hugepagesize: 2048 kB (from meminfo)
-Xmx 6144 (for java process)

And the JVM starts with -Xlp enabled.

I would assume that by vm.nr_hugepages 8GB are pinned and thus not available to other processes. But Java would only claim 6GB for Heap.

Can anyone please explain what happens to the other 2GB?

Thanks in advance!

1

There are 1 answers

1
covener On BEST ANSWER

The remaining 2GB of huge pages are pinned in continuous real memory waiting for an application to use them (the JVM config by itself won't grow the heap enough to use the remaining huge pages). That memory is unuseably for anything other then a potential caller.

Huge pages kernel options

hugepages

Defines the number of persistent huge pages configured in the kernel at boot time. The default value is 0. It is only possible to allocate (or deallocate) huge pages if there are sufficient physically contiguous free pages in the system. Pages reserved by this parameter cannot be used for other purposes.

There is a "transparent huge pages" option in later Linux releases that tries to solve some of these kinds of problems, by moving unwitting applications into any slack space that might exist, but it seems to not get much love.