directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <seelm...@apache.org>
Subject Re: A question regarding "org.apache.directory.studio.connection.core.io.jndi.JNDIConnectionWrapper" class
Date Wed, 10 Mar 2010 23:05:35 GMT
Hi Michal,

Michal Lefler wrote:
> Hi.
> 
> I was using JNDI, and I noticed that if I use JNDI connection pooling,
> "ctx.close()" does not release the context back to the pool unless I
> execute "System.gc()" explicitly.

As Emmanuel and Pierre-Arnaud already said, make sure you close every
NamingEnumeration. Additionally, if you create a sub-context using
DirContext.createSubcontext() you also need to close that sub-context.

> I looked at your " JNDIConnectionWrapper" class as a reference, and I
> saw that your "disconnect" method also executes "System.gc()".
> 
> Why did you add this call?

Well, that is the last fallback for that issue. Another reason is that
we cache a lot of entries and this call cleans up the cached objects a
bit faster.

However that is not good practice. I won't encourage you to use it. In a
client application like Studio System.gc() works well. However if your
application runs in a managed environment like an application server you
should not use it.

> Did you ran into the same problem?
> 
> Isn't there a better solution? (it is pretty ugly…)

See above.

Kind Regards,
Stefan



Mime
View raw message