/** *Programusedtocreateaheapdumpfortestpurposes.
*/ publicclass Main { // Keep a reference to the DumpedStuff instance so that it is not garbage // collected before we take the heap dump. publicstatic DumpedStuff stuff;
// If a --base argument is provided, it means we should generate a // baseline hprof file suitable for using in testing diff. boolean baseline = args.length > 1 && args[1].equals("--base");
// Enable allocation tracking so we get stack traces in the heap dump.
DdmVmInternal.setRecentAllocationsTrackingEnabled(true);
// Allocate the instance of DumpedStuff.
stuff = new DumpedStuff(baseline);
// Preemptively garbage collect to avoid an inopportune GC triggering // after this.
Runtime.getRuntime().gc();
// Create a bunch of unreachable objects pointing to basicString for the // reverseReferencesAreNotUnreachable test for (int i = 0; i < 100; i++) {
stuff.basicStringRef = new Object[]{stuff.basicString};
}
stuff.shouldNotGc();
// Take a heap dump that will include that instance of DumpedStuff.
System.err.println("Dumping hprof data to " + file);
VMDebug.dumpHprofData(file);
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.