Thread memory leak
1) I have an ATL exe server ( Freethraded) and SimpleCOM client object in
it.
When Client is opened it starts a thread ... like this:
unsigned int WINAPI _ThrRoutine( LPVOID lpParam )
{
return 0;
}
CClient::CClient()
{
HANDLE hT = (HANDLE) _beginthreadex( NULL, 0, _ThrRoutine, NULL, 0,
NULL );
WaitForSingleObject( hT, INFINITE );
CloseHandle( hT );
}
2) Now I have a client program, opening and closing the CClient object in a
loop. (local computer, CoInitializeEx( NULL, COINT_MULTITHREADED )
HRESULT hr = piClient.CoCreateInstance( __uuidof( ClientObj ) );
and after some time
piClient.Release();
3) everything is OK, when I watch the memory for the server - it is stable,
not increasing ...
4) Now I just open a simple window in the server, one time at the beginning,
.... the window is doing nothing ...
HRESULT PreMessageLoop(int nCmdShow)
{
HRESULT hr;
hr = CAtlExeModuleT< CThrTestModule >::PreMessageLoop(nCmdShow);
HWND hW = CreateWindow( L"EDIT", L"aaa", WS_POPUP, 100, 400, 100, 100,
NULL, NULL,
::GetModuleHandle(NULL), NULL );
ShowWindow( hW, SW_SHOW );
return S_OK;
}
5) now, every creating-terminating the Thread, makes some memory leak ( I
guess about 100 bytes each time ).
The consumption of memory is going up ... It should lead to crash ...
Does anybody know, what is the problem ?
thx
Antonin