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 : Alexander Grigoriev Date : Fri Apr 01 2005 06:35 am Though it's probably unrelated to your problem, casting function pointers is a bad thing. You have too many chances to screw up the calling conventions. don't also use _beginthread, use _beginthreadex instead. The former is braindead. It returns a handle, but you cannot really use it, because it may become invalid at any moment. "Larry D'Cunha" wrote in message news:456de2c6.0503302150.5348483a@posting.google.com... >I need some help debugging a program that is hanging because of a > thread problem with _beginthread() multithreaded C-runtime call. I'm > using VS6 debugger to step into the code. > > System: Xeon 3.2GHz, dual cpu, 3.2GB RAM > > Problem: > Two threads are being created. First one created ok. Second one fails. > _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. > > > I found one post out there with the exact same problem I have. > http://groups.google.ca/groups?hl=en&lr=&th=4770efc299759096&seekm=1998Jun10.061451.8665%40cmkrnl&frame=off > > It mentions that the problem could be: Running out of virtual address > space. I'm not familiar with this area, but I dont know why this is a > problem on a 3GB dual cpu machine. Something wrong with the 3GB > addressability? > > Any help appreciated. > > Thanks, > Larry > > 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. .