The issue is make-instance-fn runs in the normal jvm context so it is keeping jvm references to the produced items. It does not need to do this; the normal python reference keeping system will work just fine. Fixing this in a robust way will require some thought :-)
This will collect memory automatically:
If the user defines a dataset using clojure and this will cause issues unless the user spams (System/gc):
The issue is make-instance-fn runs in the normal jvm context so it is keeping jvm references to the produced items. It does not need to do this; the normal python reference keeping system will work just fine. Fixing this in a robust way will require some thought :-)