By +Red King,
By sweetlife,
By Konstantine · Posted
By fingletmein · Posted
By Lamp Post · Posted
By fingletmein · Posted
We rely on ads to keep creating quality content for you to enjoy for free.
Please support our site by disabling your ad blocker.
Continue without supporting us
If the prompt is still appearing, please disable any tools or services you are using that block internet ads (e.g. DNS Servers, tracking protection or privacy extensions).
Question
firey
I am writing a game in C++ using SDL as the main library, and everything seems to be going okay. However I am noticing large memory usage when I load in a texture, and freeing up pointers/objects with delete() doesn't seem to be actually freeing up memory. So on linux I used ValGrind but I find it difficult to understand where my problems are happening.
I copied my code over and have it compiling and running under Windows using Visual Studio 2010 Pro. I notice the memory usage is the same on both windows and linux, and the memory use doesn't rise constantly but it does rise when objects are created (normal), however before creation is should be deleting the one previously taking that memory space (not freeing), and using some couts I can see that it is freeing them.
ie)
MyObject *obj = new MyObject() // results in + 200kb used
delete(obj) // Doesn't reduce memory by 200kb
obj = NULL // Just sets the pointer to null
If I kept running that my memory would constantly grow by 200kb (which I think is far more than that object should be using anyways). So to try and figure out what was going on I tried adding in the leak code as stated by MS on MSDN.
http://msdn.microsoft.com/en-us/library/e5ewb1h3(v=vs.80).aspx
I put that in my main.cpp file and put the "_CrtDumpMemoryLeaks();" in my main function which looks like
AttikClient::StartGame() initializes a static function in a static class, that has the main game loop and other logic. However when I close my program there is no leak output in the output window. I have debug on as I can step through the code and can see basic output but no leak information.
I have also tried VLD (Visual Leak Detector) http://www.codeproject.com/Articles/9815/Visual-Leak-Detector-Enhanced-Memory-Leak-Detectio
And got the same results. The build mode is for sure set as debug, and I make sure to do F5 which is Debug Application. Am I missing something?
Link to comment
https://www.neowin.net/forum/topic/1155344-c-visual-studio-2010-memory-leak-tracking/Share on other sites
8 answers to this question
Recommended Posts