Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce committed heap memory in JVM

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
like image 507
Selvakumar Ponnusamy Avatar asked Apr 23 '15 14:04

Selvakumar Ponnusamy


1 Answers

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

like image 69
Evgeniy Dorofeev Avatar answered Nov 08 '22 16:11

Evgeniy Dorofeev