0

I am trying to destroy a Java object in JPype in order for garbage collection to manage the heap space, at the moment the heap space usage just keeps growing until an out of memory error is thrown. I am re-allocating the object name inside a loop, and the heap memory is sufficient for handling any specific execution of loop iteration.

What is the proper way of assigning null to a Java object in JPype?

I have tried foo = None and del foo in the hope that these will remove the references as needed in the Java Virtual Machine, but to no avail.

Edit:

I have isolated the offending lines. I am repeatedly calling

bar = jpype.JArray(jpype.JDouble, 1)(foo)

and each call seems to create an unreferenced double that is not deleted.

I have confirmed that the memory leak involves unreferenced doubles that are not deleted by analysing a memory dump.

Any suggestions will be appreciated.

Getafix
  • 121
  • 4
  • Do any other references exist to the object you're trying to get rid of? – DaveH Apr 01 '14 at 20:04
  • Eclipse Memory Analyzer on a heap dump indicates that the heap is filling up with unreachable `double[]` objects, about one for every time the loop executed before throwing the Out of Memory error. – Getafix Apr 02 '14 at 19:49
  • For this specific case, the memory leak does not occur when running on OSX, but does occur in Windows 7. – Getafix Apr 15 '14 at 18:24

0 Answers0