scott miles
scott miles

Reputation: 1517

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 ?

Upvotes: 2

Views: 2180

Answers (2)

Peter Lawrey
Peter Lawrey

Reputation: 533560

Native memory is the normal memory of an application. This is apposed to heap memory which is managed by the JVM. In a C program for example, it would be called just "memory"

Upvotes: 1

Stephen C
Stephen C

Reputation: 718946

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:

  • There will be other process on a Windows machine. Lots of them. It is just that they are system processes.

  • There possibly are OS enforced limits on how big the Java process is allowed to grow. (I'm assuming that Windows has something that fills the role of ulimit on a UNIX / Linux system.)

  • If there is disk space available for paging, the OS may actually allocate the Java process more memory than is available as physical memory pages.

Upvotes: 2

Related Questions