Subj : Re: CRT _beginthread returns -1, errno=ENOMEM "Not enough space" on 3GB dualcpu To : comp.programming.threads,comp.os.ms-windows.programmer.nt.kernel-mode,microsoft.public.vc.language From : Severian Date : Thu Mar 31 2005 10:49 pm On 31 Mar 2005 13:45:31 -0800, lpdcunha@engmail.uwaterloo.ca (Larry D'Cunha) wrote: > > >> >_beginthread() returns (-1L). I have this: >> > >> > thr = _beginthread( (void (*)(void *) )f, stk_size, (void *)arg ); >> > >> >Error code I get is: >> > 1) errno = 12, ENOMEM "Not enough space" >> > 2) GetLastError() returns 8, ERROR_NOT_ENOUGH_MEMORY >> > "Not enough storage is available to process this command." >> > >> > stk_size passed in 32768 for both threads. >> >> MSDN mentions that any thread using the C runtime requires at least a >> 64KB stack. I think this is a more likely problem in your case than >> running out of virtual address space, which you can check using >> Process Explorer from http://www.sysinternals.com, or the memory tools >> available from http://www.softwareverify.com. > >Thanks but I could not find the docs describing this limitation. I'll keep looking. I don't see it at msdn.microsoft.com, but in the 2/2003 Platform SDK it states: `Thread Stack Size ` [...] `Threads that call the C run-time library or the Windows API must `allow sufficient stack space for use of these functions. Do not `lower the reserved stack size below 64 KB. ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/dllproc/base/thread_stack_size.htm >> >p.s. Aside: I had some CRT-debug problems. I linked msvcrtd.dll >> >debug-multithreaded CRT into the app. But I could not successfully >> >step into the code for _beginthread() in thread.c CRT-source file. The >> >symbols were not found (even though I have msvcrtd.pdb in the path) >> >These files are all in my VC98 subdirectories. Oh well. >> >> Look up the MS symbol server in MSDN. It will keep your symbols >> up-to-date for all your system DLLs. You set your symbol path to a >> special string which downloads symbols for system DLLs automatically >> as needed, and updates them after service packs, updates, patches, >> etc. > >Ok, I'll give this a try. Am downloading the symbols package now. >Thanks, >Larry -- Sev .