Note that there are some explanatory texts on larger screens.

plurals
  1. POVery simple program passes VS2010 c++ memory leak checker, but still uses more memory at program end after destroying all objects?
    text
    copied!<p>I've been having trouble with a memory leak in a large-scale project I've been working on, but the project has no leaks according to the VS2010 memory checker (and I've checked everything extensively).</p> <p>I decided to write a simple test program to see if the leak would occur on a smaller scale.</p> <pre><code>struct TestStruct { std::string x[100]; }; class TestClass { public: std::vector&lt;TestStruct*&gt; testA; //TestStruct** testA; TestStruct xxx[100]; TestClass() { testA.resize(100, NULL); //testA = new TestStruct*[100]; for(unsigned int a = 0; a &lt; 100; ++a) { testA[a] = new TestStruct; } } ~TestClass() { for(unsigned int a = 0; a &lt; 100; ++a) { delete testA[a]; } //delete [] testA; testA.clear(); } }; int _tmain(int argc, _TCHAR* argv[]) { _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); char inp; std::cin &gt;&gt; inp; { TestClass ttt[2]; TestClass* bbbb = new TestClass[2]; std::cin &gt;&gt; inp; delete [] bbbb; } std::cin &gt;&gt; inp; std::cin &gt;&gt; inp; return 0; } </code></pre> <p>Using this code, the program starts at about 1 meg of memory, goes up to more than 8 meg, then at the end drops down to 1.5 meg. Where does the additional .5 meg go? I am having a similar problem with a particle system but on the scale of hundreds of megabytes.</p> <p>I cannot for the life of me figure out what is wrong.</p> <p>As an aside, using the array (which I commented out) greatly reduces the wasted memory, but does not completely reduce it. I would expect for the memory usage to be the same at the last cin as the first.</p> <p>I am using the task manager to monitor memory usage.</p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload