Jump to content
  • Advertisement
Sign in to follow this  
baykalsa

What is Leaking?

This topic is 4824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

While I was testing my map editor,I noticed that my program eats more and more memory after loading new maps.For example if no map is loaded,editor eats around 15mb,when I load a map it goes up 25mb,then with loading same map(of course deleting the old map from memory) it goes up 32mb!Then with a new load it goes up to 40mb.This is really ridicioulus ,editor should comsume same amount of memory,because I load exactly the same map after deleting it!I thought there might be memory leaks.I downloaded a bunch of software to see the leaks;Yes,there were some memory leaks.I fixed them all.But still this problem occurs.I don't understand,the memory leak detection programs show me that no memory leaks detected,but why is this problem still occurs?What do you suggest me to do?Did you have problems similar to this and how did you solve it?Please help.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
you could overload the new and delete operators and keep track of memory allocation easily.

Share this post


Link to post
Share on other sites
You were using Task Manager, weren't you... As has many times been said before this, and will doubtless be said many times after, do not use task manager to look for memory leaks! It is not accurate in that facility, get a proper leak detector, or write your own with overloaded new and deletes. I'd say that if your current leak detector says no leaks, then there are no leaks.

Share this post


Link to post
Share on other sites
Memory Managers give you a report on the memory allocate with new and deleted with delete, but maybe not with malloc() and free(). Also if you use external libraries, their allocations might not show up.

EDIT : Oh yeah, Task Manager is dumb. Don't trust it.

Share this post


Link to post
Share on other sites

Look up memory leak detection on MSDN, or similar.

Failing that and you can afford it look up boundschecker.

Share this post


Link to post
Share on other sites
Have a look at valgrind it's an excelent memory debugger that helps you
to find memory leaks (and much more).

Have a look at the implementation of smart pointers with reference counting
if you can't handle the problems manually.

Share this post


Link to post
Share on other sites
Here is one handy way to catch the memory leaks , I am using right now



#include <stdio.h>
#include <stdlib.h>

//used for debugging memory leaks
#include <crtdbg.h>


int main()
{
char *leak = (char*)malloc(64);
leak = (char*)malloc(64);

free(leak);

_CrtDumpMemoryLeaks();

return 0;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!