evmc
evmc copied to clipboard
java: clean up memory handling
Apparently the bindings should be leaking a lot of memory because references are never released, see https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.vm.80.doc/docs/jni_refs.html and https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#Release_PrimitiveType_ArrayElements_routines
I ran the VM reference tests against the EVM in a continuous loop for several hours and didn't notice a leak. It's cool to dispose of memory explicitly. I believe the JVM disposes of ByteBuffer objects it creates through garbage collection otherwise.
I ran the VM reference tests against the EVM in a continuous loop for several hours and didn't notice a leak. It's cool to dispose of memory explicitly. I believe the JVM disposes of ByteBuffer objects it creates through garbage collection otherwise.
My impression from the documentation was that these objects are part of garbage collection, but owned by the JNI interface, hence they need to be freed. They are not large objects however, so I can imagine it can lasts days before OOM.
Can you point me to the documentation where this is clarified?
Also note some of the memory freeing is already part of the code, it is inconsistent.
OK, I think I'm wrong here. You're right, let's dispose of memory explicitly.