Hi,

we face to a problem where our classloader can't be finalized by the garbage 
collector.

Let me shortly explain our context. We have an endless running application 
which has the Jess library in its classpath. Additionally we load classes with 
a custom classloader from separate jar files. These classes are used in 
deftemplate from-class statements to be used in the engine. The custom 
classloader is provided to the Rete (Rete.setClassLoader()).

I've analyzed the heap dump and found a lot of root reference chains to our 
custom classloader. All of them contain the static map 
jess.ReflectFunctions.s_descriptors. As far as I understand the code, there is 
some kind of Bean introspection for classes used in deftemplate from-class 
statements. The results of this introspection seem to be cached in this static 
map. jess.ReflectFunctions is loaded by our application classloader and holds 
static references to the deftemplate classes and hence to our custom 
classloader.

The missing classloader finalization is critical in our scenario, because all 
of its loaded classes remain in the PermGenSpace of the heap. As a result the 
application will run into OutOfMemoryExceptions over time.

At the moment I have fixed this by implementing a static clean method in 
jess.ReflectFunctions, which clears the map:

    public static void clearDescriptorsCache(){
        ReflectFunctions.s_descriptors.clear();
    }

As jess.ReflectFunctions is a package protected class, I call this new function 
from the Rete.clear() method:

        m_deffacts.clear();
        m_defglobals.clear();
        m_classSource.clear();

        //clear descriptor cache in ReflectFunctions to destroy root references 
to business model classloader
        ReflectFunctions.clearDescriptorsCache();
        
        broadcastEvent(JessEvent.CLEAR, this, m_globalContext);


Two question, I have:

Might there be problems doing it this way? If the answer is no, is it possible 
to include this as part of the next release? 



Regards,
Ralf




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
--------------------------------------------------------------------

Reply via email to