-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jni: Delete global reference in bound threads #75
Comments
Using a threadpool is probably over-complicating the solution. A single bound thread could do if performance is not a concern. If the java heap is full and needs fast deletion of global references, can java force the Haskell GC to run the finalizers promptly before java finishes garbage collection? If not, which scenario would take advantage of a fast deletion of local references? |
Next steps:
|
The current approach is to have the Haskell GC delete the global references. Unfortunately, the GC deletes global references using unbound threads which are unsafe to use when making JNI calls.
The simplest fix of all is to wrap finalizers with
Foreign.JNI.runInAttachedThread
.If the above is too slow, another solution is to implement a pool of threads to make sure finalizers are expediently executed once the GC makes up its mind to run them.
Lastly, #73 might also offer a solution to this problem.
The text was updated successfully, but these errors were encountered: