Permgen Space導致的記憶體溢位
阿新 • • 發佈:2019-01-22
問題描述
最近同事系統反饋系統出現如下錯誤:
PermGen space的全稱是Permanent Generation space,是指記憶體的永久儲存區域。
解決過程
使用jstat檢視 Permsize 佔用情況,如下所示:
using thread-local object allocation.
Parallel GC with 4 thread(s)
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 2147483648 (2048.0MB)
NewSize = 1310720 (1.25MB)
MaxNewSize = 17592186044415 MB
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 21757952 (20.75MB)
MaxPermSize = 85983232 (82.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 715259904 (682.125MB)
used = 8176712 (7.797920227050781MB)
free = 707083192 (674.3270797729492MB)
1.1431805353931876% used
From Space:
capacity = 262144 (0.25MB)
used = 0 (0.0MB)
free = 262144 (0.25MB)
0.0% used
To Space:
capacity = 262144 (0.25MB)
used = 0 (0.0MB)
free = 262144 (0.25MB)
0.0% used
PS Old Generation
capacity = 1431699456 (1365.375MB)
used = 45577208 (43.46581268310547MB)
free = 1386122248 (1321.9091873168945MB)
3.183434051678511% used
PS Perm Generation
capacity = 85983232 (82.0MB)
used = 85982928 (81.99971008300781MB)
free = 304 (2.899169921875E-4MB)
99.99964644269245% used
如上所示,可以看到PS Perm Generation被佔用了99%,分配不足。
解決方案
從上面 可以看出MaxPermSize = 85983232 (82.0MB)即永久儲存區域擴大設定
如:
對於Tomcat伺服器,則需要修改TOMCAT_HOME/bin/catalina.sh
SET JAVA_OPTS=-XX:PermSize=64 M -XX:MaxPermSize=256 M