-
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
Free attached threads #6
Comments
What is the multi-threading model that underlies this issue? Do we think that Haskell (GHC RTS) threads are controlled by Java Thread objects? I suspect that they are not. Is there an observed memory leak that gives rise to this issue? Maybe we should close this issue? |
All good questions. I believe @alpmestan originally opened this issue. @alpmestan care to elaborate? |
If I remember correctly, that's something we thought about during a discussion and that I quickly opened an issue about, to serve as a reminder. I'm pretty sure we have never investigated anything like this, and neither @mboes nor myself remember where this comes from now. I agree that this issue can be closed until 1/ we remember what we meant and 2/ we have a concrete example that exhibits some problematic behaviour. However, it is indeed not entirely obvious to figure out how the two runtimes interact as far as exceptions, threading and memory management are concerned. But without a concrete problem to solve, there's not much we can do right now. |
I'm guessing this issue refers to the AttachCurrentThread() call in the jni package, https://github.com/tweag/inline-java/blob/master/jni/src/Foreign/JNI.hs#L186. Normally, threads attached by native code should have a correspond Detach call. Attaching associates a new Java Now, this issue talks about "Haskell threads". But to clarify we're only really leaking as many So yes, I think we're leaking memory. (But for most applications, that don't use BTW,
I wouldn't put that way. I think the interactions are all fairly well understood actually. Which is not to say all the problems have been solved. Synchronous exceptions are checked for using the Java remains oblivious to RTS threads. This is fine so long as threads don't share references to Java objects (and threads that interact with the JVM, just like with OpenGL, are bound to avoid having them be moved mid-execution to another OS thread, a fact that we should document better). Note that the |
Another note: code entered via a |
* Add dependency on choice-0.2.0 * Enable parallel builds
This task is not longer relevant after the updates to address tweag/sparkle#72. The user is responsible for making JNI calls from attached threads now. JNI no longer attaches threads automatically. |
From @alpmestan on February 29, 2016 15:46
When Haskell threads die, we should tell Java about it so that it frees the corresponding
Thread
object and removes it from theThreadGroup
. Otherwise we're leaking memory.Copied from original issue: tweag/sparkle#21
The text was updated successfully, but these errors were encountered: