|
-
July 21st, 2005, 05:11 AM
#1
[RESOLVED] CreateThread only creating 27 threads max!!!
Hi Everyone,
We are porting a multi-threaded unix server application over to a win32 console app. The code over 1000000 lines long and produces a debug exe of about 20MB and a release exe of about 8MB.
We have a problem in that we can only create around 27 threads, this is not enough! Both the release and debug builds act the same!
As a test we used the following code called from the first line of main.
void AndysTestCode::CountThreads(void)
{
DWORD dwThreadId, dwThrdParam = 1;
HANDLE hThread;
char szMsg[80];
unsigned long uCount = 0;
unsigned long uFailed = 0;
for(unsigned int u=0; u< 50000; u++)
{
printf("Creating windows thread %u -", u);
hThread = CreateThread(
NULL, // default security attributes
128, // use default stack size
runWindowsThread, // thread function
&dwThrdParam, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
if (hThread == NULL)
{
printf("failed.\n" );
syserror();
}
else
printf("success.\n" );
}
LastError() when failed gives 8.
As you can see we are useing a tiny 128 stack for the test. If we change this to 1MB we get the same problem so to me it doesnt look like a stackspace issue.
If we set up a new console project the same code gives us > 2000 threads. We have set this project up to include the same libs as our main code which is basically the Oracle 9 runtime libs.
Has anyone else seen anything like this?
Any help would be really apreciated.
Cheers
Andy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|