0

Based on the description of metaspace, it only uses the native memory (no paging).

Since the class metadata is allocated out of native memory, the max available space is the total available system memory.

I found above two explanation in the internet. I have one question.

  1. The so-called native memory is located in jvm process? The native memory size = java process memory size - heap size, right? If that, why they said the max available space is the total available system memory since the maximum size of 32-bit java process is limited only to about 2G ?
liam xu
  • 2,892
  • 10
  • 42
  • 65
  • That would be the limitation of the 32bit hardware and if the hardware has limitations you can not extend it without adding more hardware capabilities. – Bilbo Baggins May 03 '16 at 08:57
  • Read this as well: http://stackoverflow.com/questions/1434779/maximum-java-heap-size-of-a-32-bit-jvm-on-a-64-bit-os – Bilbo Baggins May 03 '16 at 08:59

1 Answers1

1

it only uses the native memory (no paging).

This memory can be swapped, as required.

The so-called native memory is located in jvm process?

Native memory is in the JVM process.

The native memory size = java process memory size - heap size, right?

Native memory is all the memory the native code can see. You might want to exclude the heap.

If that, why they said the max available space is the total available system memory

This is true if you don't have an OS or architecural limitations such as

the maximum size of 32-bit java process is limited only to about 2G ?

The maximum is 4 GB, but on different OSes, portions of virtual memory are used by the OS. On Windows XP, you have only 1.2 - 1.5 GB. On Some UNIXes a 32-bit process can use 3.0 - 3.5 GB

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • Actually, on recent 32Bit Windows versions, the available user space is 3GB, but that memory is shared with code and the memory requirements of native libraries and some libraries have to be placed below the 2GB barrier, whereas Oracle’s JVM has the limitation of requiring a contiguous memory for the heap. That’s why the heap ends up having a maximum of ~1.5GB (less when more native libraries are in use), whereas on a Windows limiting the user space to 2GB, you end up having a maximum heap of roughly 1.1GB to 1.2GB (also, much less when using more native libraries). – Holger May 03 '16 at 14:33
  • @Holger My understanding is that 32-bit windows applications have to run in the Windows XP virtual environment which is works the same way for compatibility, even in Windows 10. – Peter Lawrey May 03 '16 at 14:53
  • I don’t see any contradiction. Even Windows XP supports 3GB for a user process (perhaps with SP3 only), but it has to be activated in the boot configuration. AFAIK, starting with Vista that support is on by default. But the executables (and libraries) have to have a special bit set to declare that they can cope with user addresses having their highest bit set. The JVM has that bit, but, as said, not all libraries have. So the JVM and some libraries are loaded over the 2GB barrier, but some native libs are still below, that’s why not the full 2GB are available for the heap. – Holger May 03 '16 at 15:09