1
votes

I am seeing very Large Heap Size in my Application, but used memory is very small:

Heap Size: 10 GB+ , Used Memory: 500 MB

What explains this? Why isn't Heap Size reducing. Memory Graph

My java memory params are as follows:

-Xms8448m -Xmx12544m -XX:PermSize=192m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=60

Please advice, why this strange behavior. I can see used memory being garbage collected in the graph, but whats wrong with Heap Memory????

5

5 Answers

5
votes

The initial heap Size from your argument

-Xms8448m

is over 8GB. Also, the

-Xmx12544m

gives the JVM permission to let this grow to over 12GB, and it might do this and never release it if the memory is available and it feels that is the best heap size to keep. There is simply nothing in the specifications that says the JVM should try to keep the heap size small.

2
votes

Heap size in HotSpot JVM is never going down. Though some GC algorithms cans give memory back to OS. But in later case JConsole will not show you memory reduction (in JConsole you see address space range reserved for heap), you should use OS process memory monitoring to see that JVM actually releasing memory.

Algorithms which could give unused memory back to OS are

  • serial collector (-XX:+UseSerialGC)
  • G1 (-XX:+UseG1GC)
0
votes

You're specifying the initial heap size to be ~8.5GB with -Xms8448m. Some implementations of java do not support actually shrinking the heap (often due to system limitations). Reduce this value for a smaller initial heap.

0
votes

Remove the above -Xms8448m . It specifies the initial Heap size. If you remove this it should work as expected.

0
votes

The JVM reserves the maximum heap size on start up as virtual memory. How much of this memory is main memory depends on how much is used.

When you set the minimum memory, it doesn't guarantee it is used, but it makes only minimal attempts to limit memory usage up to this point.

but why is the Heap Size sitting at almost 12 GB?

That is what you set it to be.