Tomcat異常停止
阿新 • • 發佈:2019-02-04
2014-12-04 02:25:20(UTC)左右tomcat異常停止
當前記憶體使用如下:
[email protected]:/var/log$ free -m
total used free shared buffers cached
Mem: 7974 5349 2624 0 214 2180
-/+ buffers/cache: 2954 5019
Swap: 4095 9 4086
[email protected]:/var/log$ ps uax|grep tomcat
tomcat6 24099 35.6 20.7 3277120 1692012 ? Sl 02:38 51:38 /usr/lib/jvm/java-6-sun/bin/java -Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties -Djava.awt.headless=true -server -Xms2048M -Xmx2048M -XX:MaxPermSize=512M -Djava.security.auth.login.config=/usr/share/tomcat6/conf/jaas.conf -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed -classpath /usr/share/tomcat6/bin/bootstrap.jar -Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.io.tmpdir=/tmp/tomcat6-tomcat6-tmp org.apache.catalina.startup.Bootstrap start
ops 29977 0.0 0.0 3344 716 pts/0 S+ 05:02 0:00 grep tomcat
[email protected]:/var/log$ sudo -u tomcat6 jmap -heap `ps aux|grep tomcat|grep -v grep|awk '{print $2}'`
Attaching to process ID 24099, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.1-b02
using thread-local object allocation.
Parallel GC with 4 thread(s)
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 2147483648 (2048.0MB)
NewSize = 1048576 (1.0MB)
MaxNewSize = 4294901760 (4095.9375MB)
OldSize = 4194304 (4.0MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 16777216 (16.0MB)
MaxPermSize = 536870912 (512.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 705167360 (672.5MB)
used = 94582944 (90.20132446289062MB)
free = 610584416 (582.2986755371094MB)
13.4128363513592% used
From Space:
capacity = 5242880 (5.0MB)
used = 3473528 (3.3126144409179688MB)
free = 1769352 (1.6873855590820312MB)
66.25228881835938% used
To Space:
capacity = 5308416 (5.0625MB)
used = 0 (0.0MB)
free = 5308416 (5.0625MB)
0.0% used
PS Old Generation
capacity = 1431699456 (1365.375MB)
used = 335996904 (320.4316177368164MB)
free = 1095702552 (1044.9433822631836MB)
23.468396428586754% used
PS Perm Generation
capacity = 183238656 (174.75MB)
used = 87843752 (83.77433013916016MB)
free = 95394904 (90.97566986083984MB)
47.93953083785989% used
異常日誌:
catalina.out
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate
# An error report file with more information is saved as:
# /tmp/hs_err_pid17020.log
[email protected]:/var/lib/tomcat6/logs$ cat /tmp/hs_err_pid17020.log
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate
# Possible reasons:
# The system is out of physical RAM or swap space
# In 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (allocation.cpp:211), pid=17020, tid=1384852336
#
# JRE version: 6.0_26-b03
# Java VM: Java HotSpot(TM) Server VM (20.1-b02 mixed mode linux-x86 )
--------------- T H R E A D ---------------
Current thread (0x092c9400): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=17030, stack(0x52833000,0x528b3000)]
Stack: [0x52833000,0x528b3000], sp=0x528afd90, free space=499k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
通過看log,其實已經給了我們出錯的原因和建議。
出錯原因:Native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool
建議:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
實際上,tomcat設定了2G記憶體,系統佔用了1G記憶體,再一些七七八八的記憶體佔用了300m,所以3.3G已經使用了。當執行緒比較多的時候,佔用超過700m,就會導致記憶體無法開闢而出錯
當前記憶體使用如下:
[email protected]:/var/log$ free -m
total used free shared buffers cached
Mem: 7974 5349 2624 0 214 2180
-/+ buffers/cache: 2954 5019
Swap: 4095 9 4086
[email protected]:/var/log$ ps uax|grep tomcat
tomcat6 24099 35.6 20.7 3277120 1692012 ? Sl 02:38 51:38 /usr/lib/jvm/java-6-sun/bin/java -Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties -Djava.awt.headless=true -server -Xms2048M -Xmx2048M -XX:MaxPermSize=512M -Djava.security.auth.login.config=/usr/share/tomcat6/conf/jaas.conf -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed -classpath /usr/share/tomcat6/bin/bootstrap.jar -Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.io.tmpdir=/tmp/tomcat6-tomcat6-tmp org.apache.catalina.startup.Bootstrap start
ops 29977 0.0 0.0 3344 716 pts/0 S+ 05:02 0:00 grep tomcat
Attaching to process ID 24099, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.1-b02
using thread-local object allocation.
Parallel GC with 4 thread(s)
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 2147483648 (2048.0MB)
NewSize = 1048576 (1.0MB)
MaxNewSize = 4294901760 (4095.9375MB)
OldSize = 4194304 (4.0MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 16777216 (16.0MB)
MaxPermSize = 536870912 (512.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 705167360 (672.5MB)
used = 94582944 (90.20132446289062MB)
free = 610584416 (582.2986755371094MB)
13.4128363513592% used
From Space:
capacity = 5242880 (5.0MB)
used = 3473528 (3.3126144409179688MB)
free = 1769352 (1.6873855590820312MB)
66.25228881835938% used
To Space:
capacity = 5308416 (5.0625MB)
used = 0 (0.0MB)
free = 5308416 (5.0625MB)
0.0% used
PS Old Generation
capacity = 1431699456 (1365.375MB)
used = 335996904 (320.4316177368164MB)
free = 1095702552 (1044.9433822631836MB)
23.468396428586754% used
PS Perm Generation
capacity = 183238656 (174.75MB)
used = 87843752 (83.77433013916016MB)
free = 95394904 (90.97566986083984MB)
47.93953083785989% used
異常日誌:
catalina.out
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate
# An error report file with more information is saved as:
# /tmp/hs_err_pid17020.log
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate
# Possible reasons:
# The system is out of physical RAM or swap space
# In 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (allocation.cpp:211), pid=17020, tid=1384852336
#
# JRE version: 6.0_26-b03
# Java VM: Java HotSpot(TM) Server VM (20.1-b02 mixed mode linux-x86 )
--------------- T H R E A D ---------------
Current thread (0x092c9400): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=17030, stack(0x52833000,0x528b3000)]
Stack: [0x52833000,0x528b3000], sp=0x528afd90, free space=499k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
通過看log,其實已經給了我們出錯的原因和建議。
出錯原因:Native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool
建議:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
實際上,tomcat設定了2G記憶體,系統佔用了1G記憶體,再一些七七八八的記憶體佔用了300m,所以3.3G已經使用了。當執行緒比較多的時候,佔用超過700m,就會導致記憶體無法開闢而出錯