Java – Why isn’t the allocated heap memory shrinking when usage is below MaxHeapFreeRatio

heap-memoryjava

I have a java server task, which is hogging memory. For one I doubt it ever exceeded MinHeapFreeRatio, but that's speculation. It is more interesting that GC reduces the mature generation to roughly 2%, yet never reduces the allocated memory for the heap.

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 3221225472 (3072.0MB)

   NewSize          = 268435456 (256.0MB)
   MaxNewSize       = 268435456 (256.0MB)
   OldSize          = 805306368 (768.0MB)
   NewRatio         = 7
   SurvivorRatio    = 8
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 176160768 (168.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 241631232 (230.4375MB)
   used     = 71657320 (68.3377456665039MB)
   free     = 169973912 (162.0997543334961MB)
   29.65565312351675% used
Eden Space:
   capacity = 214827008 (204.875MB)
   used     = 47322984 (45.130714416503906MB)
   free     = 167504024 (159.7442855834961MB)
   22.028414602320392% used
From Space:
   capacity = 26804224 (25.5625MB)
   used     = 24334336 (23.20703125MB)
   free     = 2469888 (2.35546875MB)
   90.78545232273838% used
To Space:
   capacity = 26804224 (25.5625MB)
   used     = 0 (0.0MB)
   free     = 26804224 (25.5625MB)
   0.0% used
concurrent mark-sweep generation:
   capacity = 2952790016 (2816.0MB)
   used     = 66930392 (63.829795837402344MB)
   free     = 2885859624 (2752.1702041625977MB)
   2.2666830908168447% used
Perm Generation:
   capacity = 45752320 (43.6328125MB)
   used     = 27404664 (26.13512420654297MB)
   free     = 18347656 (17.49768829345703MB)
   59.89786747426142% used

Best Answer

There are apparently various factors that can cause MaxHeapFreeRatio to not be honoured:

Related Topic