pyjnius icon indicating copy to clipboard operation
pyjnius copied to clipboard

Dereferencing JVM objects

Open AbdealiLoKo opened this issue 5 years ago • 0 comments

I'm trying to figure out how/if the JVM objects I create get dereferenced and available for garbage collection.

Was trying:

In [1]: import jnius

In [2]: jString = jnius.autoclass("java.lang.String")

In [8]: def abc():
   ...:     x=jString("a" * (256 * 1024 * 1024))
   ...:    # do something complex which creates a lot of big variables utilizing lots of RAM

If I call abc() multiple times, would the JVM automatically figure out that after function abc() finishes, all the Java objects created there can be garbage collected ?

I seem to be having memory issues and am trying to understand how memory management happens in the JVM with jnius

AbdealiLoKo avatar Feb 05 '19 08:02 AbdealiLoKo