Menu

QuickStart

Barak Nirenberg

The following page describes the basic steps required in order to detect memory leaks using JLeaker:

1. Find the PID (process ID) of the Java program you wish to scan for memory leaks:

Windows:

Use "Windows task manager" to find the PID (it will usually appear as a "java.exe"/"javaw.exe" process).

Linux:

Use the "ps" command line utility or similar tool.

2. Run JLeaker to scan for potential memory leaks

From the command line, run:

 jleaker --pid <PID>

The actual leaks scan will take several seconds.
All detected leaks will be printed in XML format to JLeaker's standard output stream.


Example:

In the following example JLeaker is scanning the JConsole program (provided as part of the JDK) and reports 3 suspicious maps (that thier size is greater than 300).
5 random elements from each suspicious map are printed for your convenience (in the map-element XML node), and the shortest reference chain to root reference is printed according to the referencing order (in the reference XML element).

jleaker --pid 4369
<?xml version="1.0" encoding="ISO-8859-1"?>
<memory-leaks>
    <leaking-object class="java.util.HashMap" size="2069">
            <map>
                    <map-element key="-nimbus roman no9 l-bold-i-normal-iso10646-1" value="/usr/share/ghostscript/fonts/n021024l.pfb" />
                    <map-element key="-luxi serif-medium-i-normal-iso8859-15" value="/usr/share/fonts/truetype/luxirri.ttf" />
                    <map-element key="-urw palladio l-bold-r-normal-koi8-u" value="/usr/share/ghostscript/fonts/p052004l.pfb" />
                    <map-element key="-nimbus roman no9 l-medium-i-normal-koi8-u" value="/usr/share/ghostscript/fonts/n021023l.pfb" />
                    <map-element key="-albany amt-bold-o-normal-koi8-u" value="/usr/share/fonts/truetype/albwbi.ttf" />
            </map>
            <reference-chain-to-root>
                    <reference location="sun.awt.X11FontManager.fontNameMap (Static)" />
            </reference-chain-to-root>
    </leaking-object>
    <leaking-object class="java.util.HashMap" size="2065">
            <map>
                    <map-element key="-nimbus roman no9 l-bold-i-normal-iso10646-1" value="/usr/share/fonts/URW" />
                    <map-element key="-luxi serif-medium-i-normal-iso8859-15" value="/usr/share/fonts/Type1" />
                    <map-element key="-urw palladio l-bold-r-normal-koi8-u" value="/usr/share/fonts/URW" />
                    <map-element key="-nimbus roman no9 l-medium-i-normal-koi8-u" value="/usr/share/fonts/URW" />
                    <map-element key="-albany amt-bold-o-normal-koi8-u" value="/usr/share/fonts/truetype" />
            </map>
            <reference-chain-to-root>
                    <reference location="sun.awt.X11FontManager.xFontDirsMap (Static)" />
            </reference-chain-to-root>
    </leaking-object>
    <leaking-object class="java.util.HashMap" size="344">
            <map>
                    <map-element key="VM arguments" value="VM arguments" />
                    <map-element key="Threads" value="Threads" />
                    <map-element key="Current classes loaded" value="Current classes loaded" />
                    <map-element key="Classes" value="Classes" />
                    <map-element key="Masthead.font" value="Dialog-PLAIN-25" />
            </map>
            <reference-chain-to-root>
                    <reference location="sun.tools.jconsole.resources.JConsoleResources.lookup" />
                    <reference location="sun.tools.jconsole.Resources.resources (Static)" />
            </reference-chain-to-root>
    </leaking-object>
</memory-leaks>

After analyzing the results, if you decide that these maps should be allowed to reach this mangnitude of sizes, you may create an exclussion list for them.
This will make JLeaker ignore these maps next time it runs.


MongoDB Logo MongoDB