Search code examples
javamemorygarbage-collectionheap-memory

Very Large Heap Size, But Small Used Memory


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????


Solution

  • 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.