It doesn't seem like it's possible to use valgrind or similar tools to test for memory leaks in a shared library that is used over FFI / JNI. We could potentially use the memory management trace logs to detect when an object isn't cleaned up by the time the tests finish.