[GCJ-core] dynamically unloading native libraries

Andrew Haley aph@redhat.com
Wed Nov 5 11:08:00 GMT 2008


Sylvain Marié wrote:

> Thank you for putting the topic back on the table,
> 
>> We seem to never even call JNI_OnUnload on the jni libraries.
> 
> That's exactly my point - and also even libraries that do not contain JNI at all
> (simple .so without any relation to java - I know it is not a very useful case but it is
> very simple to test with a dummy .so).
> 
> But the root cause of the problem is a bit more complex: 
> 
> a) As you mentioned, ClassLoaders don't unload unused native libraries when they are finalized.
> 
> but also
> 
> b) ClassLoaders don't even seem to be finalized when they are not used any more.
> (no alive instances, etc.)
> 
> So even correcting a) would not help, we should first try to understand why 
> ClassLoaders are never gc'ed.

Yes.  I can't think of any immediate reason why they aren't: it's a matter
worth investigating.



Andrew.



More information about the Java mailing list