Bug in phobos Thread module?

kenny funisher at gmail.com
Sat May 12 08:21:43 PDT 2007


Walter Bright wrote:
> Babele Dunnit wrote:
> 
>> I am a newbie with D but experienced C++ developer.. this is my first
>> post, so I MUST say that D ROCKS! Really impressive language. Walter,
>> you are definitely the Lord of Compilers. Back to the subject, I am
>> writing a massively multithreaded piece of code, and after some time I
>> get a "failed to start" error. I digged in the forums and found
>> someone else with same problem, but no answer. So was time to dig into
>> Thread sources...
>>
>> ...and I see a static destructor cleaning a single handle (the main
>> thread, I suppose), but no CloseHandle on any other handle created via
>> _beginthreadex (I am talking about Windows, I should have specified
>> before, sorry).
>> I believe there should be an explicit Thread destructor able to free
>> the handle via CloseHandle; also, because thread handles under Windows
>> are a limited resource, probably a RIAA scheme (or explicit "delete"
>> call) should be used, instead of waiting for the GC to pass by..
>>
>> So, I added a CloseHandle(mythread.hdl) call and now my handles count
>> (in the Task Manager) is much more under control...
> 
> I'm not too experienced with threading, so if you could post a patch
> that would be welcome.

I also experience the same issue in linux. It happens after I create/delete over 8000 threads. I dunno why 8000 is the magic number, but it is for my machine. I'll try and look into it as well on linux. Just wanted to let you know that the problem also occurs in linux



More information about the Digitalmars-d mailing list