JBoss Community

Re: KnowledgeBase keeps links to stateful sessions after disposing

created by Sergii Shyika in jBPM - View the full discussion

Hi, Tihomir,  thank you for reply. I am observing memory leak with stateless sessions too. Here is simple code below:

 

 

public static void main(String... args) {

 

        KnowledgeBase base = KnowledgeBaseFactory.newKnowledgeBase();

        waitForKeyPress();

        for (int i = 0; i ();

        for (int i = 0; i < 1000; i++) {

            list.add(new Date());

        }

        return list;

    }

 

    private static void waitForKeyPress() {

        try {

            System.in.read(new byte[2]);

        } catch (IOException e) {

            e.printStackTrace();

        }

    }

 

 

 

 

Here we simply create 500 stateless sessions and insert in each "heavy" object (list of 1000 dates).

Below is jConsole screenshot made while programm waiting for second key press:

 

http://community.jboss.org/servlet/JiveServlet/downloadImage/2-640299-17450/450-371/Memory.png

 

As you can see java process consumes ~3Mb before and 22Mb after invoiking sessions.

Below is a screenshot of my debugger, that was made  after invoiking sessions:

 

http://community.jboss.org/servlet/JiveServlet/downloadImage/2-640299-17451/450-415/Debug.png

 

You can see that knowledge base keeps 500 references to ProcessRuntime objects.

The picture is the same when we using statefull sessions and dispose them by dispose() method.

Reply to this message by going to Community

Start a new discussion in jBPM at Community