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.