javamemory-managementoperating-systemmetaspace

Is metaspace allocated out of native memory?


In Java 8, meta space is allocated out of native memory , But i did not get anywhere on net what is native memory ? Per this link it is the memory available to the OS but at Difference between Metaspace and Native Memory in Java , native memory is also shown as part of memory given to JVM process

Example :- If yes consider the case where i have 15 GB ram on windows OS. I have just one process (Java process) running on machine with -Xmx 4GB.

Does it mean OS can use up to (15-4)=11 GB out of which meta space memory will be allocated ?


Solution

  • Is metaspace allocated out of native memory?

    Yes.

    Definitive source: https://blogs.oracle.com/poonam/entry/about_g1_garbage_collector_permanent

    But i did not get anywhere on net what is native memory ?

    The native heap is the malloc / free heap that provides dynamic memory for those parts of the JVM that are implemented in native code (C++). It can also be used by user-supplied native libraries loaded by the JVM. The native heap is not garbage collected per se, but metaspace is.

    One benefit of using the native heap to hold metaspace objects is that the native heap does not have a fixed maximum size (by default) like the Java heap does.

    If yes consider the case where i have 15 GB ram on windows OS. I have just one process (Java process) running on machine with -Xmx 4GB. Does it mean OS can use up to (15-4)=11 GB out of which meta space memory will be allocated?

    Maybe: