mat
mat copied to clipboard
Add leak suspect retained heap top consumers
A leak suspect report paragraph starts with something like:
The class com.example.AllocateObject, loaded by swat#swat-war.war, occupies 187.01 MB (76.19%) bytes. The memory is accumulated in one instance of java.lang.Object[], loaded by com.ibm.oti.vm.BootstrapClassLoader @ 0xf0030fe8, which occupies 187.00 MB (76.19%) bytes.
However, it's often helpful to know what are the top handful of classes that are driving the retained heap of the leak suspect. This isn't too difficult to discover with the leak suspect details, but the main users of the tool that I see are most often just copy/pasting the leak suspect report, so if we can squeeze in some more details, that will reduce time-to-resolution in many cases.
This proposal is for a new second sentence (in bold below) that lists up to the top 3 consumers of the suspect's retained heap.
The class com.example.AllocateObject, loaded by swat#swat-war.war, occupies 187.01 MB (76.19%) bytes. Its minimum retained heap is consumed by byte[] (187 instances of 187.00 MB), java.lang.reflect.Field (16 instances of 1.00 KB), and java.lang.Object[] (1 instance of 984 B). The memory is accumulated in one instance of java.lang.Object[], loaded by com.ibm.oti.vm.BootstrapClassLoader @ 0xf0030fe8, which occupies 187.00 MB (76.19%) bytes.