2

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 ?

Community
  • 1
  • 1
scott miles
  • 1,511
  • 2
  • 21
  • 36

2 Answers2

2

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • when i say `OS can use up to (15-4)=11 GB out of which meta space memory will be allocated ` i mean OS can use up to 11 GB as and when required like for system process(as you said) . So we can say 11 GB or less can be categorized as native memory out of which metaspace will be allocated too ? – scott miles Oct 25 '16 at 16:59
  • No. It is only "native memory" if the OS has allocated it to the Java process. If not, it would be better described as "free memory" ... or "memory allocated to some other purpose". Besides, the correct terminology is "native heap" not "native memory". – Stephen C Oct 26 '16 at 01:06
  • Ok get ot But in mine example ` where i have 15 GB ram on windows OS. I have just one process (Java process) running on machine with -Xmx 4GB.` how much native memory(or native heap) OS will allocate to java process by default ? Will OS keep alllocate extra native heap from free memory if initial assigned is filled ? – scott miles Oct 26 '16 at 16:33
  • The native heap sizes grows on demand. It behaves like a C / C++ malloc heap. But at this point, I'm just repeating stuff that I said or implied by my answer. – Stephen C Oct 27 '16 at 00:45
1

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"

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130