Download Jar. Uses 3874K of libraries. Click here for Pure Java version (5908L/42K).
1 | !7 |
2 | |
3 | lib 1400084 // patched heap analyzer |
4 | |
5 | import org.gridkit.jvmtool.heapdump.*; |
6 | import org.netbeans.lib.profiler.heap.*; |
7 | import java.lang.reflect.Field; |
8 | |
9 | static Heap heap; |
10 | |
11 | sbool fake = false; |
12 | |
13 | p-experiment { |
14 | File f = stefansOS_heapDumpFile(); |
15 | print("Loading heap dump (" + toM(fileSize(f)) + " M)..."); |
16 | heap = HeapFactory.createHeap(f); |
17 | print("Got heap."); |
18 | L<JavaClass> classes = heap.getAllClasses(); |
19 | print("Got " + n2(classes, "class", "classes")); |
20 | //pnl(sortedIC(mapMethod(classes, 'getName))); |
21 | |
22 | L<JavaClass> classLoaderClasses = filter(classes, func(JavaClass c) -> bool { startsWithOneOf(c.getName(), "main$JavaXClassLoader", "x30$JavaXClassLoader") }); |
23 | print("Got " + n2(classLoaderClasses, "class loader class", "class loader classes")); |
24 | L<Instance> classLoaders = concatLists(mapMethod('getInstances, classLoaderClasses)); |
25 | print("Got " + n2(classLoaders, "class loader")); |
26 | |
27 | L<Instance> defunctClassLoaders = filter(classLoaders, func(Instance cl) { isTrue(cl.getValueOfField('retired)) }); |
28 | print("Got " + n2(defunctClassLoaders, "defunct class loader")); |
29 | |
30 | print(); |
31 | if (empty(defunctClassLoaders)) { |
32 | if (fake) { |
33 | defunctClassLoaders = classLoaders; |
34 | print("FAKING IT"); |
35 | } else { |
36 | print("No memory leaks."); |
37 | ret; |
38 | } |
39 | } |
40 | |
41 | print("Calculating GC roots..."); |
42 | |
43 | for (Instance cl : defunctClassLoaders) { |
44 | Instance progIDInstance = (Instance) cl.getValueOfField('progID); |
45 | S moduleID = HeapWalker.stringValue(progIDInstance); |
46 | print("Checking module ID: " + snippetWithTitle_cached(moduleID)); |
47 | print("\nPath to GC root:"); |
48 | printLinesWithGrowingIndent(map(func(Pair<Instance, S> p) -> S { |
49 | joinNempties(" in ", p.b, heapWalker_className(p.a)) |
50 | }, heapWalker_pathToGCRootWithFieldNames(cl))); |
51 | print(); |
52 | //Instance i = cl.getNearestGCRootPointer(); |
53 | //print("i => " + i); |
54 | } |
55 | } |
Began life as a copy of #1016518
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016891 |
Snippet name: | Find references to defunct class loaders in Stefan's OS heap dump v2 [dev.] |
Eternal ID of this version: | #1016891/6 |
Text MD5: | fc7113785fb798675e535cfdcf1293bd |
Transpilation MD5: | 5f4c7414308135c1affe354aabe7b249 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-06 18:46:21 |
Source code size: | 1940 bytes / 55 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 538 / 1216 |
Version history: | 5 change(s) |
Referenced in: | [show references] |