msxml with the "NoFullGC" registry key leaks memory with CoFreeUnusedLibraries
I am trying to use NoFullGC registry setting to disable the garbage collector in MSXML. (as per http://support.microsoft.com/kb/304227) This however causes a memory leak each time a background thread in the application calls CoFreeUnusedLibraries(). Is there a solution/work around? Instructions 1) Set "NoFullGC" to 1 reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSXML60 /v NoFullGC /t REG_DWORD /d 1 2) Compile this program For example: cl /MD /W4 /WX msxml_leak.cpp 3) Run and check memory use in taskmgr: it increases over time 4) Remove the registry key reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSXML60 /v NoFullGC Notes Also leaks with MSXML30/DOMDocument30 and MSXML40/DOMDocument40 Environment msxml6.dll (6.20.1099.0) on Windows Server 2003 Analysis When the Tls slot is 0 on entry to DllCanUnloadNow() the msxml library allocates memory in AllocTlsData. However it doesn't appear to free it, and when GC is disabled the memory simply leaks. -------------------------- msxml_leak.cpp ------------------------ #include <windows.h> #include <process.h> #include <stdio.h> #import "msxml6.dll" void Check(void*) { CoInitialize(0); for ( int i = 0; i != 10000000; ++i) { CoFreeUnusedLibraries(); ::Sleep(1); } CoUninitialize(); } int main() { CoInitialize(0); { MSXML2::IXMLDOMDocumentPtr pXmlDoc; pXmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60)); _beginthread(Check, 0, 0); MessageBox(NULL, "Press when finished", "Msxml leak tester", MB_OK); } CoUninitialize(); }
November 19th, 2010 5:24am

Hello Roger, As this issue is related to Development, I would like to suggest that you initiate a new thread in our MSDN forum for better and accurate answer to the question. The community members and support professionals there are more familiar with it and can help you in a more efficient way. For your convenience, I have listed the Forum link below: MSDN Forums http://social.msdn.microsoft.com/Forums/en/categories/ BrentPlease remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
November 21st, 2010 8:26pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics