Hi!

I've been profiling an application using Jackrabbit by means of BindableRepository. I have noticed that on consequetive redeployments a lot of memory is not freed (check the attached picture).
As you can notice a lot of this space is used by java.lang.Shutdown which keeps 
the shutdown hooks.

The application has context listeners that are correctly unregistering the BindableRepository (using RegistryHelper).

My proposed patch is the following:

1/ keep the shutdown hook thread in the BindableRepository after init is called;
2/ if the BindableRepository.shutdown is correctly called by means of RegistryHelper than remove the shutdown hook

Attached is also the patch generated upon BindableRepository v.307128.


What is your opinion on this?

./alex
--
.w( the_mindstorm )p.



Index: 
D:/workspace/java/cvsprojects/svn/jackrabbit/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
===================================================================
--- 
D:/workspace/java/cvsprojects/svn/jackrabbit/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
       (revision 350050)
+++ 
D:/workspace/java/cvsprojects/svn/jackrabbit/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
       (working copy)
@@ -82,6 +82,8 @@
     /** The delegate repository instance. Created by [EMAIL PROTECTED] #init() 
init}. */
     private transient Repository delegatee;
 
+    private transient Thread hook;
+    
     /**
      * Creates a BindableRepository instance with the given configuration
      * information, but does not create the underlying repository instance.
@@ -122,11 +124,13 @@
         RepositoryConfig config =
             RepositoryConfig.create(configFilePath, repHomeDir);
         delegatee = RepositoryImpl.create(config);
-        Runtime.getRuntime().addShutdownHook(new Thread() {
+        hook= new Thread() {
             public void run() {
                 shutdown();
             }
-        });
+        };
+        
+        Runtime.getRuntime().addShutdownHook(hook);
     }
 
     //-----------------------------------------------------------< Repository >
@@ -247,5 +251,6 @@
      */
     void shutdown() {
        ((RepositoryImpl) delegatee).shutdown() ;
+        Runtime.getRuntime().removeShutdownHook(hook);
     }
 }

Reply via email to