How to reduce committed heap memory in JVM

12,336

You can try to tune -XX:MaxHeapFreeRatio which is "maximum percentage of heap free after GC to avoid shrinking". Default value = 70

Share:
12,336
Selvakumar Ponnusamy
Author by

Selvakumar Ponnusamy

I'm a Full stack Java developer, working in a Startup company. Im interested in Scalable Architecture, Microservices, Performance Engineering, TDD, Java, NodeJS, ReactJS, Docker, AWS, IOT Feel free to visit https://medium.com/@selvakumar.ponnusamy/, just documented few solutions I come across.

Updated on June 27, 2022

Comments

  • Selvakumar Ponnusamy
    Selvakumar Ponnusamy almost 2 years

    Our JVMs are consuming more memory than expected. We did some profiling and found that there is no leak. Used heap memory goes till 2.9 GB max but it comes down to 800 MB during idle time. But committed heap increased till 3.5 GB (sometimes 4 GB) and never comes down. Also after the idle time, when used heap increases from 800 MB, then committed heap memory gets increased from 3.5 GB. So our server reaches max memory size soon and we have to restart them every other day.

    My questions are

    1. My understanding is that committed heap memory is currently allocated memory. When used heap memory reduces why is the committed memory not getting reduced as well?
    2. When used heap memory increases from its level (800 MB) committed heap memory also get increased from its level (from 3.5GB)

    We have the below memory settings in our servers:

    -Xmx4096M -Xms1536M -XX:PermSize=128M -XX:MaxPermSize=512M