WeakHash Classloader

H

horndude77

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
 
C

Chris Uppal

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
 
E

EJP

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top