mat icon indicating copy to clipboard operation
mat copied to clipboard

[Fix #114] Add leak suspect retained heap top consumers

Open kgibm opened this issue 7 months ago • 1 comments
trafficstars

As per #114, add a new second sentence (in bold below) that lists up to the top 3 consumers of the suspect's retained heap; for example:

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 totaling 187.00 MB), java.lang.reflect.Field (16 instances totaling 1.00 KB), and java.lang.Object[] (1 instance totaling 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.

I wrestled with whether to use snapshot.getMinRetainedSet or snapshot.getRetainedSet. I ended up going with the former (and putting "minimum retained heap" in the message) because the leak suspects report can already run a bit long and I think the goal in the summary is just to get out quick first pass useful information rather than super precise information.

Also added an optional -Dorg.eclipse.mat.inspections.LeakHunterQuery.keywords=false JVM argument to hide the keywords section. There was some discussion on a bug or mailing list about this some years ago and the decision was to not change the default behavior, but I'd like to override this for our IBM Support servers as it causes some confusion.

Also added the option to specify an explicit BytesDisplay for BytesFormat in case someone ever wants to explicitly show a value as B/KB/MB/GB/etc. I ended up deciding against using it to match the rest of the leak suspects report (using whatever is set as the preference), but I thought it was worth keeping in there in case it's useful in the future.

kgibm avatar Apr 09 '25 16:04 kgibm