Download Jar. Uses 0K of libraries. Click here for Pure Java version (5462L/38K).
!7 // finds references to defunct class loaders lib 1400084 // patched heap analyzer import org.gridkit.jvmtool.heapdump.*; import org.netbeans.lib.profiler.heap.*; import java.lang.reflect.Field; static Heap heap; sbool fake = false; p { consoleIcon(#1101624); centerHigherConsole(); tt(); if (isAbsolutePath(first(args))) setUserHome(first(args)); File f = stefansOS_heapDumpFile(); print("Loading heap dump (" + toM(fileSize(f)) + " M)..."); heap = HeapFactory.createHeap(f); print("Got heap."); L<JavaClass> classes = heap.getAllClasses(); print("Got " + n2(classes, "class", "classes")); //pnl(sortedIC(mapMethod(classes, 'getName))); L<JavaClass> classLoaderClasses = filter(classes, func(JavaClass c) -> bool { startsWithOneOf(c.getName(), "main$JavaXClassLoader", "x30$JavaXClassLoader") }); print("Got " + n2(classLoaderClasses, "class loader class", "class loader classes")); L<Instance> classLoaders = concatLists(mapMethod('getInstances, classLoaderClasses)); print("Got " + n2(classLoaders, "class loader")); L<Instance> defunctClassLoaders = filter(classLoaders, func(Instance cl) { isTrue(cl.getValueOfField('retired)) }); print("Got " + n2(defunctClassLoaders, "defunct class loader")); print(); if (empty(defunctClassLoaders)) { if (fake) { defunctClassLoaders = classLoaders; print("FAKING IT"); } else { print("No memory leaks."); ret; } } print("Calculating GC roots..."); for (Instance cl : defunctClassLoaders) { Instance progIDInstance = (Instance) cl.getValueOfField('progID); S moduleID = HeapWalker.stringValue(progIDInstance); print("Checking module ID: " + snippetWithTitle_cached(moduleID)); print("\nPath to GC root:"); printLinesWithGrowingIndent(map(func(Pair<Instance, S> p) -> S { joinNempties(" in ", p.b, heapWalker_className(p.a)) }, heapWalker_pathToGCRootWithFieldNames(cl))); print(); //Instance i = cl.getNearestGCRootPointer(); //print("i => " + i); } }
Began life as a copy of #1016517
download show line numbers debug dex old transpilations
Travelled to 29 computer(s): aoiabmzegqzx, ayivmpnvhhik, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, dbzfplsxganw, ekrmjmnbrukm, gwrvuhgaqvyk, hpgrupgrauku, ippswpntdvcc, irmadwmeruwu, ishqpsrjomds, jchfcwwgaovw, lpdgvwnxivlt, mqqgnosmbjvj, nnlgzsuogrvb, pyentgdyhuwx, pzhvpgtvlbxg, qaafgiputhfz, qmtsvidgarql, sekmkcqzslie, tslmcundralx, tvejysmllsmz, vouqrxazstgt, vzdtmrzilvqm, wdffvflfhhdx, whxojlpjdney, wpzdwgqboxjy, zkbeyrirjpvi
No comments. add comment
Snippet ID: | #1016518 |
Snippet name: | Stefan's OS memory leak finder [OK] |
Eternal ID of this version: | #1016518/61 |
Text MD5: | 6fb8b4df95e06c65864ba7eaf25a4c3e |
Transpilation MD5: | e80bd9d5a588a457f855b983025224d0 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-03-26 14:13:35 |
Source code size: | 2111 bytes / 64 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 708 / 2727 |
Version history: | 60 change(s) |
Referenced in: | [show references] |