taglibs-user@jakarta.apache.org
[Top] [All Lists]

Re: <c:set> and runtime expressions

Subject: Re: <c:set> and runtime expressions
From: Luca Passani
Date: Wed, 05 Apr 2006 17:32:35 +0200
Kris Schneider wrote:

The implication that the example singleton class causes a memory leak just because "...it creates a hard reference to a class instance into the class itself" is hard to believe. There are plenty of other ways to pin classes loaded by the web app's class loader, but the singleton pattern isn't one of them.

One common way to pin classes is through the JavaBeans Introspector. Since the Introspector caches information about the classes it processes, those references will keep the web app's class loader from becoming eligible for collection. If you're using a container that doesn't take this into account, the common solution is to create a ServletContextListener that calls Introspector.flushCaches in its contextDestroyed method.

If your singleton is really causing a performance issue, there's probably something else going on. If it's released open source, you might want to post a link to the code so someone can take a look at it.

Great. I would love to be educated about this subject. It gets so tricky at times :)
Here is the class that "initializes" the Singleton

http://cvs.sourceforge.net/viewcvs.py/wurfl/tools/java/wurflapi-xom/antbuild/src/net/sourceforge/wurfl/wurflapi/ObjectsManager.java?rev=1.3&view=markup

this API is meant to be used in command-line, GUI-based and web applications alike. The main reason to introduce the singleton was to avoid that my object is garbage collected (re-creating the object implies parsing a 3Megs XML file, so garbage collection should be avoided at all costs).

Thanks

Luca



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: taglibs-user-help@xxxxxxxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>