What is this tool?
To detect slow memory leak in java heap area, this tool extracts difference of each object numbers between two java heap hisograms before and after leaking memory.
Before using this tool, you have to get two java heap histgrams with the following command before and after memory leak.
jmap -histo:live [java process id] > [text filename]
I only test this tool for jmap command bundled in Oracle JVM - especially, Java 6.
How to use this tool
This tool is written in Java. So just execute this as a Java appliction with adding this jar file to CLASSPATH. The usage is similar to UNIX diff command like the following.
java quitada.JavaObjectDiff [java histogram file before memory leak] [java histogram file after memory leak]
You will see the following output showing the difference of the number of each obejcts and sort them in descending order like the following.
diff class name
The first column indicates the difference of the number of each objects. The second column indicates class name for each objects. Larger the number of differences, the object may cause memory leak. So you can start to detect where causes memory leak based on the class name of the object.
This tool doesn't provide complete solutions to detect memory leak. But this will narrow down the problem domain especially for users who don't have commercial tools to detect memory leak or can't attach those tools in their production system.