当使用率低于MaxHeapFreeRatio时

当使用率低于MaxHeapFreeRatio时

本文介绍了当使用率低于MaxHeapFreeRatio时,为什么分配的堆内存不会缩小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个java服务器任务,它占用了内存。我怀疑它曾经超过MinHeapFreeRatio,但这是猜测。更有趣的是,GC将成熟生成减少到大约2%,但从不减少堆的分配内存。

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


推荐答案

显然有各种因素可能导致MaxHeapFreeRatio无法兑现:

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


  • 最小堆大小( -Xms )会覆盖此(AFAIK)。

  • -XX:ParallelGC开关禁止堆缩小 -

  • 收缩仅在完整的GC之后发生 -

  • The minimum heap size (-Xms) overrides this (AFAIK).
  • The -XX:ParallelGC switch inhibits heap shrinking - https://forums.oracle.com/forums/thread.jspa?messageID=6438432
  • The shrinkage only happens after a full GC - https://forums.oracle.com/forums/thread.jspa?messageID=9557861

这篇关于当使用率低于MaxHeapFreeRatio时,为什么分配的堆内存不会缩小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 06:44