scott miles scott miles - 9 months ago 83
Java Question

Used vs Max vs Size -Jvisualvm?

In jvisual vm i see three attributes under Monitor>Heap, i see 3 attributes depicting memory details all with differnt figures

  1. Size : ?

  2. Used :- I believe this is the actual memory used

  3. Max :- I believe this is the max heap size allocated to java process (specified with Xmx)

I am not sure what size actually depicts?

Answer Source

The three attributes can be defined as next:

  1. Size: The actual total reserved heap size
  2. Used: The actual used heap size.
  3. Max: The max size of the Java heap (young generation + tenured generation)

Indeed when you launch your JVM, the initial heap size (can be defined with -Xms) will be the initial total reserved heap size, then according to how your application behaves, it could need to increase the total reserved size until it reaches the max size and if it is still not enough you could get OOME.