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
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.
Found what I wanted.
Once I did this, Visual Studio no longer reported any memory leaks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With