Isn’t always correct, since a GC may happen between the two method calls. Runtime.getRuntime().freeMemory() but obviously not the used memory. We can retrieve the total memory via Runtime.getRuntime().totalMemory() and the free memory via The first naive approach is asking the JVM how much memory is used. Of the consumed memory is essential when comparing the different implementations.
Java tool memory monitor code#
When benchmarking code with memory/time trade offs, keeping track The throughput can be improved by increasing the memory. Within the same amount of memory and yield a better throughput.Ī cache is a typical example of the memory/time or space/time trade off. More memory then the other, the cache library with the better memory footprint can obviously store more entries Contrary, when one cache is consuming effectively Is described in more detail at the end of the article.Ī cache library could “cheat” and store more entries then configured. The graph shows the throughput in operations per second for a capacity limit of 1M entries. Let’s look at a benchmark result:įor the graph above there is an Alternative Image and Raw Data available.
Metric: Maximum Used Memory via GC Notification.Metric: Used Memory after Forced GC and Settling.Metric: Object Graph Traversing Libraries.