public static long heapUsed() {
        return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
    }
Returns the amount of heap memory used by the JVM in bytes.
tools/src/main/java/org/apache/kafka/tools/automq/perf/MemoryMonitor.java