Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Class Reloading and Load Time Weaving

I'm working on a project that generates a lot of code and uses a
custom ClassLoader to pull generated classes into the JVM.  My
structure allows for reloading (by orphaning the old loader and
creating a new one) in the event that code is regenerated.
Additionally, I have enabled load-time weaving to add some behavior to
the generated classes as they are loaded.

My problem here is that once I enable load-time weaving, orphaned
class loaders are *not* garbage collected.  With some investigation,
I'm pretty convinced that the Load Time Weaver is holding on to
references of class loaders that have otherwise been abandoned.  As
long as a reference is maintained to the loader, it will not be
garbage collected, and all of the classes it loaded will similarly
stay in memory.

The bottom line is that this is a memory leak.  Classloaders (and
Classes they load) are never released, so every reload increases
memory usage, until the VM eventually crashes.  Is there a way for me
to tell AspectJ to release a classloader that is no longer being used?

Thanks,
Eric Grunzke


Back to the top