Community

Removing cached entry in VFSCLPolicy on load

created by Ales Justin in JBoss Microcontainer Development - View the full discussion

Does something like this make sense to add directly, or should it be optional?

 

   public VFSClassLoaderPolicy(String name, VirtualFile[] roots, VirtualFile[] excludedRoots)
   {
        ...
 
        this.excludedRoots = excludedRoots;
+      addClassFoundHandler(new VFSCacheRemove());
    }
 
+
+   private class VFSCacheRemove implements ClassFoundHandler
+   {
+      public void classFound(ClassFoundEvent event)
+      {
+         String className = event.getClassName();
+         String path = ClassLoaderUtils.classNameToPath(className);
+         vfsCache.remove(path); // remove the entry once we loaded the class
+      }
+   }
 }

 

This would definitely decrease the memory, since every already loaded class's lookup cache would be released.

And with CL cache fixed, we access the class on next invocaton directly form CL cache, hence no need to path cache.

Reply to this message by going to Community

Start a new discussion in JBoss Microcontainer Development at Community