Created
December 23, 2011 03:43
-
-
Save rednaxelafx/1513061 to your computer and use it in GitHub Desktop.
get class histogram in GC log on OutOfMemoryError
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat > OOM.java | |
import java.util.*; | |
public class OOM { | |
public static void main(String[] args) throws Exception { | |
ArrayList list = new ArrayList(); | |
while (true) { list.add(new byte[20000]); } | |
} | |
} | |
$ javac OOM.java | |
$ java -XX:OnOutOfMemoryError='kill -3 %p' -XX:+PrintClassHistogram -Xmx10m -Xloggc:/tmp/gc.log OOM | |
# | |
# java.lang.OutOfMemoryError: Java heap space | |
# -XX:OnOutOfMemoryError="kill -3 %p" | |
# Executing /bin/sh -c "kill -3 15353"... | |
2011-12-23 11:09:48 | |
Full thread dump OpenJDK 64-Bit Server VM (22.0-b02-internal-fastdebug mixed mode): | |
"Low Memory Detector" daemon prio=10 tid=0x0000000056eff800 nid=0x3c05 runnable [0x0000000000000000] | |
java.lang.Thread.State: RUNNABLE | |
JavaThread state: _thread_blocked | |
Thread: 0x0000000056eff800 [0x3c05] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0 | |
JavaThread state: _thread_blocked | |
"C2 CompilerThread1" daemon prio=10 tid=0x0000000056efd000 nid=0x3c04 waiting on condition [0x0000000000000000] | |
java.lang.Thread.State: RUNNABLE | |
JavaThread state: _thread_blocked | |
Thread: 0x0000000056efd000 [0x3c04] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0 | |
JavaThread state: _thread_blocked | |
"C2 CompilerThread0" daemon prio=10 tid=0x0000000056ee8800 nid=0x3c03 waiting on condition [0x0000000000000000] | |
java.lang.Thread.State: RUNNABLE | |
JavaThread state: _thread_blocked | |
Thread: 0x0000000056ee8800 [0x3c03] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0 | |
JavaThread state: _thread_blocked | |
"Signal Dispatcher" daemon prio=10 tid=0x0000000056ee6000 nid=0x3c02 runnable [0x0000000000000000] | |
java.lang.Thread.State: RUNNABLE | |
JavaThread state: _thread_blocked | |
Thread: 0x0000000056ee6000 [0x3c02] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0 | |
JavaThread state: _thread_blocked | |
"Finalizer" daemon prio=10 tid=0x0000000056e63000 nid=0x3c01 in Object.wait() [0x00000000423bf000] | |
java.lang.Thread.State: WAITING (on object monitor) | |
JavaThread state: _thread_blocked | |
Thread: 0x0000000056e63000 [0x3c01] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0 | |
JavaThread state: _thread_blocked | |
at java.lang.Object.wait(Native Method) | |
- waiting on <0x00000000ffaa32e8> (a java.lang.ref.ReferenceQueue$Lock) | |
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118) | |
- locked <0x00000000ffaa32e8> (a java.lang.ref.ReferenceQueue$Lock) | |
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134) | |
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159) | |
"Reference Handler" daemon prio=10 tid=0x0000000056e60800 nid=0x3c00 in Object.wait() [0x00000000422be000] | |
java.lang.Thread.State: WAITING (on object monitor) | |
JavaThread state: _thread_blocked | |
Thread: 0x0000000056e60800 [0x3c00] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0 | |
JavaThread state: _thread_blocked | |
at java.lang.Object.wait(Native Method) | |
- waiting on <0x00000000ffaa3490> (a java.lang.ref.Reference$Lock) | |
at java.lang.Object.wait(Object.java:485) | |
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116) | |
- locked <0x00000000ffaa3490> (a java.lang.ref.Reference$Lock) | |
"main" prio=10 tid=0x0000000056d8f000 nid=0x3bfa runnable [0x0000000040a41000] | |
java.lang.Thread.State: RUNNABLE | |
JavaThread state: _thread_blocked | |
Thread: 0x0000000056d8f000 [0x3bfa] State: _call_back _has_called_back 1 _at_poll_safepoint 0 | |
JavaThread state: _thread_blocked | |
at oom.main(oom.java:6) | |
"VM Thread" prio=10 tid=0x0000000056e46800 nid=0x3bff runnable | |
"GC task thread#0 (ParallelGC)" prio=10 tid=0x0000000056da7800 nid=0x3bfb runnable | |
"GC task thread#1 (ParallelGC)" prio=10 tid=0x0000000056da9800 nid=0x3bfc runnable | |
"GC task thread#2 (ParallelGC)" prio=10 tid=0x0000000056dab800 nid=0x3bfd runnable | |
"GC task thread#3 (ParallelGC)" prio=10 tid=0x0000000056dad800 nid=0x3bfe runnable | |
"VM Periodic Task Thread" prio=10 tid=0x0000000056f03800 nid=0x3c06 waiting on condition | |
Compiler thread printing unimplemented. | |
JNI global references: 92 | |
Heap | |
PSYoungGen total 3008K, used 2621K [0x00000000ffcb0000, 0x0000000100000000, 0x0000000100000000) | |
eden space 2624K, 99% used [0x00000000ffcb0000,0x00000000fff3f7d0,0x00000000fff40000) | |
from space 384K, 0% used [0x00000000fffa0000,0x00000000fffa0000,0x0000000100000000) | |
to space 384K, 0% used [0x00000000fff40000,0x00000000fff40000,0x00000000fffa0000) | |
PSOldGen total 6848K, used 6836K [0x00000000ff600000, 0x00000000ffcb0000, 0x00000000ffcb0000) | |
object space 6848K, 99% used [0x00000000ff600000,0x00000000ffcad2a0,0x00000000ffcb0000) | |
PSPermGen total 21248K, used 2143K [0x00000000fa400000, 0x00000000fb8c0000, 0x00000000ff600000) | |
object space 21248K, 10% used [0x00000000fa400000,0x00000000fa617de0,0x00000000fb8c0000) | |
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space | |
at oom.main(oom.java:6) | |
$ cat /tmp/gc.log | |
0.347: [GC 2610K->2554K(9856K), 0.0082460 secs] | |
0.358: [GC 5171K->5045K(9856K), 0.0074010 secs] | |
0.366: [Full GC 5045K->5036K(9856K), 0.0175010 secs] | |
0.385: [Full GC 7655K->7637K(9856K), 0.0184070 secs] | |
0.404: [Full GC 9448K->9448K(9856K), 0.0163090 secs] | |
0.421: [Full GC 9448K->9399K(9856K), 0.0204180 secs] | |
0.442: [Full GC 9447K->9447K(9856K), 0.0157920 secs] | |
0.458: [Full GC 9447K->9439K(9856K), 0.0143060 secs] | |
0.472: [Full GC 9458K->9458K(9856K), 0.0143570 secs] | |
0.487: [Full GC 9458K->9458K(9856K), 0.0140480 secs] | |
0.536: [Full GC 9458K->190K(8448K), 0.0316810 secs] | |
num #instances #bytes class name | |
---------------------------------------------- | |
1: 4696 643360 <methodKlass> | |
2: 4696 576088 <constMethodKlass> | |
3: 310 352176 <constantPoolKlass> | |
4: 282 243552 <constantPoolCacheKlass> | |
5: 310 221808 <instanceKlassKlass> | |
6: 376 73904 [B | |
7: 740 67528 [C | |
8: 367 44432 java.lang.Class | |
9: 489 31840 [[I | |
10: 453 29032 [S | |
11: 741 23712 java.lang.String | |
12: 40 23360 <objArrayKlassKlass> | |
13: 355 18720 [I | |
14: 310 13104 [Ljava.lang.Object; | |
15: 8 4672 <typeArrayKlassKlass> | |
16: 11 2112 <klassKlass> | |
17: 58 1856 java.util.Hashtable$Entry | |
18: 48 1792 [Ljava.lang.String; | |
19: 17 1360 [Ljava.util.HashMap$Entry; | |
20: 15 720 java.util.HashMap | |
21: 7 720 [Ljava.util.Hashtable$Entry; | |
22: 11 704 java.net.URL | |
23: 16 640 java.util.concurrent.ConcurrentHashMap$Segment | |
24: 19 608 java.util.concurrent.ConcurrentHashMap$HashEntry | |
25: 19 608 java.util.Locale | |
26: 15 600 java.util.LinkedHashMap$Entry | |
27: 5 560 java.lang.Thread | |
28: 16 512 java.util.concurrent.locks.ReentrantLock$NonfairSync | |
29: 14 448 java.util.HashMap$Entry | |
30: 11 440 java.lang.ref.SoftReference | |
31: 5 440 java.lang.reflect.Method | |
32: 6 432 java.lang.reflect.Constructor | |
33: 16 416 [Ljava.util.concurrent.ConcurrentHashMap$HashEntry; | |
34: 10 400 java.io.ObjectStreamField | |
35: 13 312 java.io.ExpiringCache$Entry | |
36: 9 288 java.security.AccessControlContext | |
37: 1 288 <methodDataKlass> | |
38: 6 288 java.util.Hashtable | |
39: 12 264 [Ljava.lang.Class; | |
40: 8 256 java.lang.OutOfMemoryError | |
41: 15 240 java.lang.Object | |
42: 6 192 java.util.Vector | |
43: 8 184 [Ljava.io.ObjectStreamField; | |
44: 7 168 java.io.File | |
45: 4 160 java.lang.ref.Finalizer | |
46: 2 160 [Ljava.lang.ThreadLocal$ThreadLocalMap$Entry; | |
47: 4 160 sun.misc.URLClassPath$JarLoader | |
48: 5 120 java.util.ArrayList | |
49: 2 112 sun.nio.cs.StreamEncoder | |
50: 2 112 java.io.ExpiringCache$1 | |
51: 1 112 java.lang.ref.Reference$ReferenceHandler | |
52: 1 112 java.lang.ref.Finalizer$FinalizerThread | |
53: 4 96 sun.misc.MetaIndex | |
54: 2 96 java.io.BufferedWriter | |
55: 2 96 java.nio.HeapByteBuffer | |
56: 3 96 java.util.Stack | |
57: 2 96 sun.nio.cs.UTF_8$Encoder | |
58: 3 96 java.lang.ThreadLocal$ThreadLocalMap$Entry | |
59: 2 96 java.lang.ThreadGroup | |
60: 2 80 java.io.ExpiringCache | |
61: 1 80 [Ljava.util.concurrent.ConcurrentHashMap$Segment; | |
62: 5 80 java.lang.ThreadLocal | |
63: 1 80 sun.misc.Launcher$ExtClassLoader | |
64: 3 72 sun.reflect.NativeConstructorAccessorImpl | |
65: 3 72 sun.misc.Signal | |
66: 1 72 sun.misc.Launcher$AppClassLoader | |
67: 3 72 java.lang.RuntimePermission | |
68: 3 72 java.io.FileDescriptor | |
69: 2 64 java.io.FileOutputStream | |
70: 2 64 java.lang.VirtualMachineError | |
71: 2 64 java.security.Permissions | |
72: 2 64 [Ljava.lang.Thread; | |
73: 2 64 java.io.PrintStream | |
74: 4 64 java.util.concurrent.atomic.AtomicInteger | |
75: 2 64 sun.misc.URLClassPath | |
76: 2 64 java.lang.ref.ReferenceQueue | |
77: 2 64 java.io.OutputStreamWriter | |
78: 2 64 java.lang.ref.ReferenceQueue$Null | |
79: 4 64 java.lang.ref.ReferenceQueue$Lock | |
80: 1 48 [J | |
81: 3 48 sun.reflect.DelegatingConstructorAccessorImpl | |
82: 2 48 java.nio.charset.CoderResult | |
83: 1 48 java.util.concurrent.ConcurrentHashMap | |
84: 2 48 sun.misc.NativeSignalHandler | |
85: 1 48 java.util.Properties | |
86: 2 48 java.lang.ThreadLocal$ThreadLocalMap | |
87: 3 48 java.lang.Integer | |
88: 2 48 java.io.BufferedOutputStream | |
89: 3 48 java.nio.charset.CodingErrorAction | |
90: 2 40 [Ljava.io.File; | |
91: 1 40 java.io.BufferedInputStream | |
92: 1 40 sun.nio.cs.StandardCharsets$Aliases | |
93: 1 40 sun.nio.cs.StandardCharsets$Classes | |
94: 1 40 sun.nio.cs.StandardCharsets$Cache | |
95: 1 40 java.security.ProtectionDomain | |
96: 1 32 java.lang.NullPointerException | |
97: 1 32 java.lang.ArithmeticException | |
98: 1 32 [Ljava.lang.OutOfMemoryError; | |
99: 1 32 java.util.Collections$SynchronizedMap | |
100: 1 32 java.security.BasicPermissionCollection | |
101: 1 32 java.io.FilePermission | |
102: 1 32 sun.nio.cs.StandardCharsets | |
103: 1 32 java.lang.ref.Reference | |
104: 1 32 java.io.UnixFileSystem | |
105: 1 32 java.util.concurrent.atomic.AtomicReferenceFieldUpdater$AtomicReferenceFieldUpdaterImpl | |
106: 1 32 [Ljava.lang.ThreadGroup; | |
107: 2 32 java.util.HashSet | |
108: 1 32 java.security.CodeSource | |
109: 2 32 sun.net.www.protocol.jar.Handler | |
110: 2 32 java.lang.Boolean | |
111: 1 32 java.lang.ClassLoader$NativeLibrary | |
112: 1 32 sun.misc.SoftCache | |
113: 1 32 java.io.FileInputStream | |
114: 2 32 java.nio.ByteOrder | |
115: 1 24 java.util.Collections$EmptyMap | |
116: 1 24 sun.nio.cs.UTF_8 | |
117: 1 24 sun.misc.URLClassPath$FileLoader | |
118: 1 24 java.lang.reflect.ReflectPermission | |
119: 1 24 java.util.BitSet | |
120: 1 24 java.security.Policy$UnsupportedEmptyCollection | |
121: 1 24 java.io.FilePermissionCollection | |
122: 1 16 java.io.FileDescriptor$1 | |
123: 1 16 java.lang.reflect.ReflectAccess | |
124: 1 16 java.util.Collections$ReverseComparator | |
125: 1 16 java.security.ProtectionDomain$2 | |
126: 1 16 java.lang.Terminator$1 | |
127: 1 16 java.security.ProtectionDomain$Key | |
128: 1 16 sun.jkernel.DownloadManager$1 | |
129: 1 16 [Ljava.security.Principal; | |
130: 1 16 sun.net.www.protocol.file.Handler | |
131: 1 16 java.nio.charset.CoderResult$1 | |
132: 1 16 java.lang.String$CaseInsensitiveComparator | |
133: 1 16 java.nio.charset.CoderResult$2 | |
134: 1 16 java.security.AccessControlContext$1 | |
135: 1 16 [Ljava.lang.StackTraceElement; | |
136: 1 16 sun.misc.Launcher | |
137: 1 16 sun.reflect.ReflectionFactory | |
138: 1 16 java.lang.System$2 | |
139: 1 16 java.lang.ref.Reference$Lock | |
140: 1 16 [Ljava.security.cert.Certificate; | |
141: 1 16 sun.misc.Launcher$Factory | |
142: 1 16 java.util.Collections$EmptySet | |
143: 1 16 java.lang.Runtime | |
144: 1 16 java.util.Hashtable$EmptyEnumerator | |
145: 1 16 java.util.Hashtable$EmptyIterator | |
146: 1 16 java.net.URLClassLoader$7 | |
147: 1 16 java.util.Collections$EmptyList | |
148: 1 16 sun.misc.Unsafe | |
149: 1 16 java.net.UnknownContentHandler | |
Total 14749 2390184 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment