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

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.
 
G

Guest

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
 
G

Guest

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top