user36568
user36568

Reputation: 67

Java off heap memory and huge pages

When allocating off-heap memory in Java (through direct buffers, or JNI native code for example), will the allocated memory be backed by huge pages if the JVM is using -XX:+UseLargePages ?

Upvotes: 0

Views: 798

Answers (1)

apangin
apangin

Reputation: 98495

No, HotSpot JVM uses a plain libc malloc call to allocate memory for a direct ByteBuffer.

However, if you replace the standard system allocator with, for example, jemalloc - you'll be able to configure malloc to use huge pages when available.

Another option to use huge pages for direct ByteBuffers is to create a file on a hugetlbfs filesystem and then map it in Java as a MappedByteBuffer.

Upvotes: 4

Related Questions