At 15:27 15.08.2003 -0400, Matt_Conway@... wrote:
>jython-dev-admin@... wrote on 08/14/2003 08:03:11 PM:
> > python.options.internalTablesImpl = weak
> > makes the PyJavaClass entries collectible.
>Ok, I spoke too soon - this almost does the trick. The problem is that my
>custom classloader does not get garbage collected because the
>PyJavaClass.tbl only has the PyJavaClass as a Weak reference - the actual
>Class (which refs the classoader) which is a key in that table never gets
no, there is code such that when PyJavaClass weak ref has become invalid,
the corresponding entry Class -> weak(PyJavaClass) will be removed.
The code is triggered on table access, or through
That means generally, that when the PyJavaClasses are collected then at some
point the classes will be removed from the table and then if they didn't live
outside the table, the classloader and the classes will be collected.
If you want to be sure that what is collectible has been collected at some
But if PyJavaClass intances or classes or classloaders are around outside
the table, they cannot be collected.
>Is there any reason the Class key couldn't be a weak reference too?
for the weak impl, in absolute terms, none. I presume I favored code reuse,
speed when I wrote that.
Now I think that weak ought to be the default, the problem is then
trashing, because the weak impl guarantees uniquess but not to keep the
PyJavaClass around as long as the class is around and across GCs. So the
PyJavaClass, if it's not kept alive outside the table, can need to be
recreated more than once, which can be costly.