feedback / send your comments
mail to luc peuvrier
chat channel
joafip users mailing list
forums

UP

Memory leak detection

Currently working on a solution based on heap snapshot based on JVM heap dump tool
The JOAFIP implementation is limited : do not browse the whole heap

Since JOAFIP make able to manage more objects than memory can contains, it is important that all objects read or wrote are deleted from memory when data access session is closed.

To check if achieving the goal a tool has been add to detect memory leak. This the role of MemInspector class to create list of object in memory ( weak references ) and make able to see added object from an object list to another. All object in memory have a reference path from the root object.

download memory inspector jar

download memory inspector source

Example of checking file persistence memory link:

        /* get the memory inspector service instance */
        final MemInspector memInspector = MemInspector.getInstance();
        /* Only interested by creation of object from joafip package class */
        memInspector.setMainPackageName("net.sf.joafip");
        bob1.setBob2(new Bob2());
        /*
         * After doing initialization and some object storing, get the object in
         * memory in initial object map.
         */
        memInspector.inspect(this, false/* markNew */);
        /* add an object */
        bob1.setBob3(new Bob3());
        /*
         * Get the object in memory and log those added to initially in memory
         */
        memInspector.inspect(this, true/* markNew */);
        /*
         * is there object added
         */
        System.out.println("added object :"+memInspector.added());//NOPMD
        /*
         * output in text file
         */
        final PrintStream stream = new PrintStream(new File("runtime/mem.txt"));
        memInspector.log(stream);
        stream.close();
        /*
         * output for ShowObjectTree
         */
        memInspector.xstreamTree(new File("runtime/mem.xml"));


Below the log obtained, this is the objects that stay in memory after a data access session usage. A path to object staying in memory to root object is also log for debug purpose.

* class net.sf.joafip.meminspector.MainTestMemInspector 20181463
  * class net.sf.joafip.store.service.objectfortest.Bob1 9042915
    = class net.sf.joafip.store.service.objectfortest.Bob2 32425490
    + class net.sf.joafip.store.service.objectfortest.Bob3 6794265


Or using net.sf.joafip.meminspector.service.ShowObjectTree


feedback / send your comments
mail to luc peuvrier
chat channel
joafip users mailing list
forums

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
© 2007-2012, joafip