Message5831

Author matt_brinkley
Recipients adam.spiers, bpedman, matt_brinkley, pjenvey, rkurin, zyasoft
Date 2010-06-23.17:38:39
SpamBayes Score 3.5685312e-05
Marked as misclassified No
Message-id <1277314721.41.0.505174764319.issue1522@psf.upfronthosting.co.za>
In-reply-to
Content
I tried this out and it didn't work. After applying the patch I created a test app that recreates the problem: it is a java program that creates a PythonInterpreter that runs a python script which contains a python class that implements a java interface. After running the the script I print out the size of class_to_type, do an explicit System.gc(), and print out the size again. This whole process it done in a loop, and the output indicates that the size of class_to_type increases by one on each iteration.

I looked at the source again and I think I know why this didn't work: The weak hash map only contains weak references to the *key*, not the value (it contains a normal strong reference to the value.) The javadocs for WeakHashMap indicate that if the value has a strong reference to the key then the weak hash map will never release that entry, because the (key has a strong reference through the value back to the gc root.) This is exactly the case here: the PyJavaType value contains a reference to the key in its member variable "javaProxy" (you can see this assignment in PyJavaType.java:203)
History
Date User Action Args
2010-06-23 17:38:41matt_brinkleysetmessageid: <1277314721.41.0.505174764319.issue1522@psf.upfronthosting.co.za>
2010-06-23 17:38:41matt_brinkleysetrecipients: + matt_brinkley, pjenvey, zyasoft, bpedman, rkurin, adam.spiers
2010-06-23 17:38:41matt_brinkleylinkissue1522 messages
2010-06-23 17:38:39matt_brinkleycreate