gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSThread limits?


From: Richard Frith-Macdonald
Subject: Re: NSThread limits?
Date: Mon, 7 Apr 2008 15:54:57 +0100


On 7 Apr 2008, at 03:30, Marc Wan wrote:

hello!

 I am looking to create a server that maintains a pool of a few
hundred threads at a time, and being a fan of objective-c, i had hoped
to be able to use GNUStep to do this on non-mac platforms.

 unfortunately, I don't seem to be able to fork more than about
150-160 threads using
NSThread::detachNewThreadSelector:toTarget:withObject.  on my macs
here, i can easily do 1000 (i didn't test higher).

 after this on Linux, I get:

: Uncaught exception NSInternalInconsistencyException, reason: Unable
to detach thread (unknown error)


 i had worried that this was a linux (ubuntu 6.10 LTS Server) issue,
but /proc/sys/kernel/thread-max says that it'll handle over 143000
threads ... some casual browsing of NSThread.m didn't immediately show
any limitations.

 any idea why this might be happening?

Probably you are using a buggy version of the gnu objc runtime, and are not using a new enough vewrsion of GNUstep to have the workaround for the bug.

There is a known bug where the runtime incorrectly creates threads as joinable, which means they consume resources we don't want them to, and thus limit the number of threads available to GNUstep.

You can get a version of the compiler/runtime without the bug, or you can use the workaround we have in GNUstep svn, which is to add a call to 'pthread_detach(pthread_self())' immediately after the call to 'objc_thread_set_data(self)' when a new thread is starting (that's in the private mathod _sendThreadMethod in older versions of NSThread.m).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]