[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[aspectj-users] Class Reloading and Load Time Weaving
- From: "Eric Grunzke" <eric.grunzke@xxxxxxxxx>
- Date: Thu, 15 Nov 2007 15:12:27 -0700
- Delivered-to: firstname.lastname@example.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=bOfA6M+jp+f/UWbQpJ8yGfnHePvgl6lGJEeUewxPKfs=; b=KVU207qm+IBr1dWCfn7oS1pU0DOJeBcg4d38JVh3B/O8Ke3HigM8GyzxO4AgV/+KfWgbsNyLdVxdLC/rMa6LnkqouvnXemmqpUSDa+Pb/KKfAI4bap/8ea8nCV+x2E0rv8Sy9Db9aRfnIZTObr3n+spU8pfUMMhXXsuuJKPt+sA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=OAaJEOEK9+6r+D9JhepZ8ggte0Qno+L2+3hqvUbqD3+hf/xG4NhigprvMZUovn9VXCowcD78Cc/5jAxPuIW3RBVAciBCo+U/rSKS+jslV2zjy5gFs2AgCrQyyypl2mCoRNr/lhZEiVGmXn22/IV3LPGaF9RWpoArmm+76Nt89BM=
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?