Hello All,

I'm facing a little problem while cleaning up the memory. I'm using my
MFC Regular Dll (using shared MFC DLL) in my own created ATL Service
(EXE). This service is being initiated and destroyed by a main server
application. When my main server application recieves WM_QUIT
messages, it further sends KILL messages to all the components and
clients currently attached to the server. The service also closes but
after 2 seconds delay of the main application, with an error message
of "Unreferenced Memory". This memory leak does not effect any of my
application performance but still enough for eye catching. When I
debug the application from the main server, I came to this point:

This _tWinMain is the entry point of my ATL service....

extern "C" int WINAPI _tWinMain(HINSTANCE hInstance,
HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/)
{
|
|
|

#if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
#else
HRESULT hRes = CoInitialize(NULL);
#endif
|
|
|
|
| Some Work Done
|
|
|
|


_Module.Term();
CoUninitialize();
return nRet;
}

After wWinMainCRTStartup() -> Exit -> DoExit() -> ExitProcess()->
_DllMainCRTStartup()->DllMain(),

I reached over here.
This is the point from where the exception is raising.

************************************************** *********************

CSimpleList::GetHead()
CTypedSimpleList:perator CDynLinkLibrary *()
AfxTermExtensionModule(AFX_EXTENSION_MODULE & {...}, int 0)

************************************************** **********************

I'm unable to locate the reason for all this. As all of the OLE
initialization is balanced in each n every module. Here, I'm not sure
ab't my knowledge of all pre-requistites of using Regular Dlls with in
ATL Service (Out of proc. Server).

Kindly anybody let me know if there is any workaround for the current
problem. What should I do to get rid of it.

Thanks In Advance.
Your quick response will be a gr8 gr8 kindness for me.

Thanks Again

Naveed Ahmed Siddiqui
Islamabad, Pakistan.