I created a Java class with a static void method that
does nothing and got the same results. The Python
script below shows that the Java heap and Python
garbage collector are not reporting any changes, but
the working set memory usage still grows.
This seems to indicate that the memory leak is not from
object creation or objects being passed in either
direction, but from method invocation.
--- test.py ---
import jpype
import gc
jpype.startJVM(r"C:\Program
Files\Java\jdk1.5.0_07\jre\bin\client\jvm.dll", "-cp
test")
testPackage = jpype.JPackage("test")
for i in xrange(100000000):
testPackage.Test.doNothing()
if i % 10000 == 0:
jpype.java.lang.Runtime.getRuntime().gc()
gc.collect()
print
jpype.java.lang.Runtime.getRuntime().freeMemory()
print len(gc.get_objects())
---
--- test.java ---
package test;
public class Test
{
public static void doNothing()
{
return;
}
}
---
Python test script
fixed jp_methodoverload.cpp
Logged In: YES
user_id=585104
I found the leak in jp_methodoverload.cpp. There were new
statements in JPMethodOverload::invokeStatic,
JPMethodOverload::invokeInstance, and
JPMethodOverload::invokeConstructor that didn't have
corresponding deletes. Adding them fixes the problem
outlined above. I've attached the fixed source file; next
I'll try to generate a diff.
Logged In: YES
user_id=423569
thank you. No need to go about generating diff for 3
functions. Simply tell me which lines were changed. Thats
actually easier for me to change than using a diff :)
Logged In: YES
user_id=423569
Originator: NO
I ended up using the "cleaner" pattern I used for everything else