Hello,
I'm wanting to make a classloader which when all classes contained in
certain jars no longer have any live objects their classloader is
garbage collected. My initial idea was to use a WeakHash so the
classloader would automatically be garbage collected when memory is
needed, but I couldn't quite get that to work (I don't have the code
right now, but maybe I'll post that later). The reason we would like
this is because the memory for our project is constrained and we need
to have a fairly long uptime. After running a while having all these
extra classes around which are not always needed becomes a big
limitation.
So I'm wondering if this is possible or if you could point me in the
right direction. Thanks for the help!
-----Horndude77
Chris Uppal - 10 May 2006 11:51 GMT
> I'm wanting to make a classloader which when all classes contained in
> certain jars no longer have any live objects their classloader is
> garbage collected. My initial idea was to use a WeakHash so the
> classloader would automatically be garbage collected when memory is
> needed, but I couldn't quite get that to work (I don't have the code
> right now, but maybe I'll post that later).
I don't think there's anything wrong with the general idea (although I don't
really see what you would use your WeakHashMap for). It can be tricky to get
the details right, though.
-- chris
EJP - 11 May 2006 02:32 GMT
> I'm wanting to make a classloader which when all classes contained in
> certain jars no longer have any live objects their classloader is
> garbage collected.
Isn't that how classloaders work anyway? if there is no other reference
to the classloader that is, outside the classes it has loaded.