I have an MFC project, that is linking to a third party dll. At program exit, the IDE reports back that "Detected memory leaks!" and dumps the leaks.
These leaks are from the third party dll. I'm pretty sure that these are falsely being reported. (A quick Google check states that MFC checks for memory leaks, before the CRT destroys variables at the file scope.)
Is there a way to disable the memory leak check, only for that dll?
In response to the answer posted so far
I don't think I'm misusing the API. The behavior I suspect can be reproduced with a simple project
- Using VS2005
- Create a new solution.
- Create a new project (MFC application.)
- Create a new project (Windows 32 Project, Application Type: DLL, Export Symbols)
- In the dll project, export a function.
- In the dll project, define class Foo as follows
Here's the code
class foo
{
public:
foo(void) { p = new int; };
~foo(void) { delete p; }
private:
int* p;
};
In the dll project, create an instance of the class foo, scoped at the file level.
foo g_foo;
// This is an example of an exported function.
TEMPDLL_API int exportedFunction(void)
{
return 42;
}
In the MFC project, link to the library, and call the exported function in InitInstance()
Running the application, will report a memory leak, even though p is deleted, when the destructor for g_foo is called.