Original Post
I recently posted about a memory leak that was detected by MMGR, that was the result of std::list usage of a memory pool. So knowing that this wasn't really a memory leak, someone (i think it was Sneftel, thanks!) pointed out that I should just include nommgr.h before my standard includes, and mmgr.h afterwards. Well, that seemed simple enough, however I seem to still get the std::list "leak" reported by mmgr. So my question is: what is the proper way to integrate mmgr into a project. Before you say "RTFM", I would like to add that I did Read The Finger-licking-good Manual, but I am still having troubles. I understand that I should order my includes as follows: standard includes mmgr.h project includes There are a few questions about this though. Does this require me to have all of my includes in the .h files? Sometimes I throw an include in the .cpp when the .cpp is using something that is internal to that class, and doesn't need to be accessible to other classes that includes this file. Or should I have an "engine.h" like what is found in the Enginuity series here on gamedev, and include mmgr.h in that file? I have included a small working example of a possible use of mmgr, but this mmgr will report a leak allocated by "??(00000)::??". If i put a break point in the mmgr's new operator overload, I find that this is allocation originates from std::list. See for yourself: "header1.h" "main.cpp" I would appreciate any helpful feedback on this matter. Thanks. [EDIT] To clarify, I know why mmgr thinks this is a memory leak (see link) But I would like to know how I can organize my project so that mmgr does not report this as a leak.
#ifndef HEADER1_TEST_H__
#define HEADER1_TEST_H__
#include "nommgr.h"
#include <iostream>
#include <list>
#include "mmgr.h"
class Foo
{
private:
std::list<std::string> stringList;
public:
Foo() {}
~Foo() {}
};
#endif
#include "header1.h"
int main(void)
{
Foo* foo = new Foo();
return 0;
}