Why Out of memory error when trying to create a thread?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using MS Visual C++ .NET, Windows XP, and 1GB RAM.
Why could be the reason why I get an error message saying

Out of memory

when running the following code

CClientThread* pThread = (CClientThread*)
AfxBeginThread(RUNTIME_CLASS(CClientThread), THREAD_PRIORITY_NORMAL, 0,
CREATE_SUSPENDED);

My application does only have this additional thread.
 
Have you tried something simpler like

GetDlgItem(IDOK)->EnableWindow(FALSE);
AfxBeginThread(ComputeThreadProc, GetSafeHwnd(), THREAD_PRIORITY_HIGHEST);

where ComputeThreadProc is your global function executed by the thread ?
(like advised in the KrulingskyShepperdWingo's book)

good luck

Xav
 
Thanks Xav,

That's a worker thread, right?! I'm trying to create a multi-threaded server
which can serve several clients simultaneously, and I have heard that you
need user interface threads for this purpose.

Regards,
Joachim
 
a stupid suggestion, but I dare :
"Out of memory" makes me think of something not instanciated.
In your piece of code I see a CClientThread *Thread without any "new"
anywhere ?
Xav
 
Back
Top