I have a Windows service that exposes a COM object that accepts requests defined as XML documents - a sort of propretry SOAP I guess. Anyway, the COM method signature looks like this: HRESULT Server::Execute(BSTR in, BSTR* out) { /* ... */ } The first thing I do is turn the string into an XML document. I've tried using the document implementations in MSXML3, MSXML4 and MSXML6. We recently added a request that's called with a high frequency and it highlighted that creating an XML document leaks a semaphore and an event handle (even if the object is properly released). In all the other web posts I've found, I've seen other people with this problem but no one has found a general solution. One idea is to do this: HRESULT Server::Execute(BSTR in, BSTR* out) { CoInitialize(NULL); /* ... */ CoUninitialize(); } And this works fine in my simple console test program. But in a Windows service, I need to expose the COM object and I can only do this if the thread has already called CoInitialize(...).