OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Memory leak in calls to CoCreateInstanceEx

From: Wagner Schalch (wagner.schalchTRANSPORT.ALSTOM.COM)
Date: Fri Feb 20 2004 - 05:00:19 CST


Hello,

        I am calling CoCreateInstanceEx from inside a loop that is broken
when the call succeeds. When I use a CLSID from a class not registered in
my system, the calls to CoCreateInstanceEx fail and the loop becomes an
infinite loop. Observing the Task Manager, I have realized that the memory
consumption is increasing by 8K from time to time... Have anyone
expirienced something similar???

        A sample code that would simulate my problem is the following:

int main(int argc char* argv[])
{
        CoInitialize( NULL );

        IAnyInterface* pObject = NULL;

        COSERVERINFO csi = { 0, L"MyComputer", 0, 0 };

        MULTI_QI qiS[1];

        qiS[0].pIID = &IID_IAnyInterface;
        qiS[0].hr = 0;
        qiS[0].pItf = NULL;

        for(;;)
        {
                HRESULT hr = CoCreateInstanceEx( CLSID_ClassNotRegistered,
0, CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, &csi, 1, qiS );
                if( FAILED( hr ) )
                {
                        Sleep( 10 );

                        continue;
                }

                pObject = (IAnyInterface*)qiS[0].pItf;

                break;
        }

        CoUninitialize();

        return 0;
}

Regards,
Wagner Schalch

:.________________
CONFIDENTIALITY : This e-mail and any attachments are confidential and
may be privileged. If you are not a named recipient, please notify the
sender immediately and do not disclose the contents to another person, use
it for any purpose or store or copy the information in any medium.

----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.html
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM