Package cz.drg.pregrouper.util
Class MemoryReport
java.lang.Object
cz.drg.pregrouper.util.MemoryReport
Programmatic memory introspection for a running JVM — everything Runtime
doesn't tell you. Verified on OpenJDK 21.
Run the host app with -XX:NativeMemoryTracking=summary to enable nativeMemory().
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidbuffers()Direct and mapped buffer pools.static StringInstance count + bytes per class.static voiddumpAll()Everything at once.static voidWrite a heap dump for offline analysis in Eclipse MAT / VisualVM.static StringInvoke any jcmd diagnostic command in-process.static longmappingResidentBytes(String fileNameFragment) Resident bytes of a specific file's mapping, from /proc/self/smaps (Linux).static StringCategorised native memory.static voidpools()Heap and non-heap pools: Eden, Survivor, Old, Metaspace, code heaps, class space.static voidProcess virtual size vs resident set — the only way to see mmap residency.static voidCumulative bytes allocated per live thread — shows which thread is churning.
-
Method Details
-
pools
public static void pools()Heap and non-heap pools: Eden, Survivor, Old, Metaspace, code heaps, class space. -
buffers
public static void buffers()Direct and mapped buffer pools. NOTE: for "mapped", memoryUsed is the total mapped *address space*, not resident pages — see residency() for that. -
threadAllocation
public static void threadAllocation()Cumulative bytes allocated per live thread — shows which thread is churning. -
residency
Process virtual size vs resident set — the only way to see mmap residency.- Throws:
Exception
-
mappingResidentBytes
Resident bytes of a specific file's mapping, from /proc/self/smaps (Linux).- Throws:
Exception
-
jcmd
Invoke any jcmd diagnostic command in-process.- Throws:
Exception
-
classHistogram
Instance count + bytes per class. Stops the world; not for hot paths.- Throws:
Exception
-
nativeMemory
Categorised native memory. Requires -XX:NativeMemoryTracking=summary.- Throws:
Exception
-
heapDump
Write a heap dump for offline analysis in Eclipse MAT / VisualVM.- Throws:
Exception
-
dumpAll
public static void dumpAll()Everything at once.
-