How could I prevent memory leaks in following simple init/shutdown
application?
-------
#include "stdafx.h"
#include "nsXPCOMGlue.h"
#include "nsIServiceManager.h"
#include "nsXPCOM.h"
#include "nsCOMPtr.h"
#include "nsStringAPI.h"
#include "nsComponentManagerUtils.h"
int _tmain(int argc, _TCHAR* argv[])
{
#ifdef _DEBUG
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF |
_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF);
//_CrtSetBreakAlloc(96);
#endif
nsresult rv;
rv = XPCOMGlueStartup(0);
if ( NS_FAILED(rv) )
{
std::cerr<<"XPCOMGlueStartup() failed\n";
return -1;
}
nsIServiceManager* service_manager;
rv = NS_InitXPCOM2( &service_manager, nsnull,nsnull);
if ( NS_FAILED(rv) )
{
std::cerr<<"Calling NS_InitXPCOM returns ["<<rv<<"].\n";
return -1;
}
rv=NS_ShutdownXPCOM(service_manager);
if ( NS_FAILED(rv) )
{
std::cerr<<"ShutdownXPCOM failed.\n";
}
XPCOMGlueShutdown();
return 0;
}
-------
Visual Studio detects multiple leaks, some of them (all?) originating
from NS_ShutdownXPCOM. Sure i could ignore shutdown memory leaks but
this noise prevents detecting of 'real' memory leaks. Using debug build
of firefox-1.5.0.4-source.
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom