[jboss-user] [jBPM] New message: "Re: jBPM 4.3 - Will cause memory leaks due to unclosed InitialContext()"

Santanu Saraswati do-not-reply at jboss.com
Fri Jan 22 16:06:19 EST 2010

User development,

A new message was posted in the thread "jBPM 4.3 - Will cause memory leaks due to unclosed InitialContext()":


Author  : Santanu Saraswati
Profile : http://community.jboss.org/people/saraswati.santanu

    Did you really faced any OutOfMemoryError because of this?
    Typically InitialContext context = new InitialContext() does not take a lot of resources and build a new context altogether. InitialContext just works as a delegate to the actual initial context created using some environment variables/ jndi.properties. When you do a new InitialContext() it asks the InitialContextFactory for the actual InitialContext, and it will be suicidal if the InitialContextFactory creates a new context whenever somebody calls getInitialContext() on it. And I can assure that no proper InitialContextFactory implementation does that. So calling close should not be required at all.
    Now what if I call close? Well the code in IntialContext.java is this:
*    public void close() throws NamingException {
        myProps = null;
        if (defaultInitCtx != null) {
            defaultInitCtx = null;
        gotDefault = false;
    So this closes the defaultInitContext, which is the JNDI context of the server. So if I do so, any further initial context lookup in my application is going to fail !! It will be interesting to see what happens if I call close. It should depend on the implementation and the implementation should understand that the real intention is not to close.


To reply to this message visit the message page: http://community.jboss.org/message/521841#521841

More information about the jboss-user mailing list