Re: dead threads
From: Holger Kreißl (hok_at_inormatik.tuchemnitz.de)
Date: 02/13/04
- Next message: mosfet: "delete and exception"
- Previous message: crimson13: "menu in a dialogbar"
- In reply to: Jagadeesh VN: "Re: dead threads"
- Next in thread: Alexander Grigoriev: "Re: dead threads"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 13 Feb 2004 16:14:46 +0100
> The message clearly says that the CWinThread object is not deleted. When
you
> call AfxBeginThread(), a new object is created for you.
> The object isn't deleted until the thread terminates, and is only deleted
> automatically by MFC if the thread's m_bAutoDelete member is TRUE.
>
> You can always notify your main thread before exiting from the current
> thread using messages. Use SendMessage(...)/PostMessage(..).
>
> Or
>
> Use Events...( CreateEvent(),SetEvent(), and WaitforMultipleObjects() )
>
> "Vadim Maksimenko" <vadimax@vrm.lt> wrote
> > To be sincere, I do not use MFC threading, so I have no idea of its
> > internals. Most likely memory leak is in MFC itself "by design". Using
> > standard WIN32 API you must poll threads from time to time about their
> > status, and close handles if some threads became inactive (terminated).
> > Those functions are CreateThread(), GetExitCodeThread(), and
> CloseHandle().
> >
I installed a counter for the running threads. He should be zero at the end
of the work. An he is! ?? So it looks like all threads are terminating
correctly. I tested it by calling about hundred threads. But there ist
mostly only one leak.
I do something like that in the called SrvThreadProc to count the threads:
UINT SrvThreadProc(LPVOID pParam)
{
iActiveThreads++;
CMyServer newThread(pParam);
UINT ret = 0;
ret = newThread.ServerThreadMain();
iActiveThreads--;
return ret;
}
So how can it be, that there are some (not much) leaks, when the counter
iActiveThreads is zero after he has done his work?
Thanks for your hints,
Greets, Holger
- Next message: mosfet: "delete and exception"
- Previous message: crimson13: "menu in a dialogbar"
- In reply to: Jagadeesh VN: "Re: dead threads"
- Next in thread: Alexander Grigoriev: "Re: dead threads"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|