2
Runtime.getRuntime().maxMemory() 

shows which memory ? Is it Survivor , Eden , Old, Permanent ?

RNJ
  • 15,272
  • 18
  • 86
  • 131
VJS
  • 2,891
  • 7
  • 38
  • 70

2 Answers2

3

It is the maximum size of the heap. It is loosely based on the -mx or -Xmx command line argument but for reasons I don't understand can be 1-5% less (It doesn't seem to be ever exactly the same)

What this doesn't include is the perm gen, the direct memory, memory mapped files, stack spaces or shared libraries.

While it doesn't include everything is it usually 80-90% the total memory usable for most applications.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 1
    For future readers: the missing difference between `-Xmx` and `getRuntime().maxMemory()` is the size of a single Survivor space (because at the same time, only one survivor space can be used). – G. Demecki Mar 17 '17 at 10:32
2

According to API, Returns the maximum amount of memory that the Java virtual machine will attempt to use. If there is no inherent limit then the value Long.MAX_VALUE will be returned.

Vallabh Patade
  • 4,960
  • 6
  • 31
  • 40