Menu

#45 Memory Leak

Version 0.5
closed-fixed
9
2007-08-13
2006-11-03
Colin Evans
No

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;
}
}
---

Discussion

  • Colin Evans

    Colin Evans - 2006-11-03

    Python test script

     
  • Colin Evans

    Colin Evans - 2006-11-08

    fixed jp_methodoverload.cpp

     
  • Colin Evans

    Colin Evans - 2006-11-08

    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.

     
  • Steve Menard

    Steve Menard - 2006-11-09

    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 :)

     
  • Steve Menard

    Steve Menard - 2007-08-13

    Logged In: YES
    user_id=423569
    Originator: NO

    I ended up using the "cleaner" pattern I used for everything else

     
  • Steve Menard

    Steve Menard - 2007-08-13
    • priority: 5 --> 9
    • status: open --> closed-fixed
     

Log in to post a comment.