[Issue 19487] Thread never detaches after spawn

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 11 14:43:57 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19487

er.krali at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |er.krali at gmail.com

--- Comment #3 from er.krali at gmail.com ---
I think that the issue is that the thread is never joined properly.

I have an application that listens to a socket and spawns a new thread for each
(very short-lived) incoming connection, and I have to run `joinLowLevelThread`
to get a proper cleanup. And for that each running thread has to send back its
id to its parent using `Thread.getThis.id`.

Also, thread_joinAll doesn't work in my case either because it waits for all
the threads... in order. And I happen to have some other long lived threads, so
it blocks there and never cleans up anything.

Part of the issue is that you can't get the underlying Thread object from
`spawn`, so there's no way to join it. The other part, of course, is that this
is not taken care of automatically.

Incidentally, it also leaks memory like hell, I can see the GC usage
continuously growing and no amount of GC.collect or GC.minimize can get rid of
it, so the data must be being kept somewhere...

--


More information about the Digitalmars-d-bugs mailing list