Bennu Game Development

English Forums => General => Topic started by: MisterN on April 14, 2012, 05:14:42 PM

Title: Is there a way to check for memory leaks?
Post by: MisterN on April 14, 2012, 05:14:42 PM
Is there a way to check for memory leaks? Cause my game used to be 8mb in the task manager and after a line of code it become 13+mb, and then reverting back it stayed the same. So im all confused lol.
Title: Re:Is there a way to check for memory leaks?
Post by: handsource-dyko on April 15, 2012, 03:19:53 PM
Well, that's a tough one. There can be so many different reasons. First you'll have to find out if it caused by your own code, and you really suspect it to be an external factor (such as bgdi itself) you could post a question on the board. But, the memory usage of programs is not constant, it can fluctuate especially if it loads/unloads files or allocates/frees memory. This doesn't happen imidiatly, there can be a delay, because the operating system has to do it's bookkeeping with memory allocation.

A memory leak can be easely caused by loading files and not unloading them after use. The program will use increasingly more memory untill windows says it's enough and then force terminates the program. (When a program uses about 2 GB of memory on a 32 bit windows system it becomes critical because windows won't allow a program to use any more, unless you have the professional version and a processor with support for physical adress extensions). Basically if it crosses the line the program will crash.

But finding the cause for a memory leak can be difficult, and requires a lot of time if you don't have any "suspects" in the code.
Title: Re:Is there a way to check for memory leaks?
Post by: BlackCurtain on April 18, 2012, 10:02:03 PM
I always unload stuff I don't need at the end of a process below
onexit
Title: Re:Is there a way to check for memory leaks?
Post by: Sandman on August 18, 2012, 07:04:59 AM
Late to the party, but there's a library that tries to help in this matter. I hope it still works...
http://forum.bennugd.org/index.php?topic=262.0
Title: Re:Is there a way to check for memory leaks?
Post by: handsource-dyko on August 18, 2012, 08:14:06 AM
Sandman, you're back!  :)
Title: Re:Is there a way to check for memory leaks?
Post by: Kloppix on August 18, 2012, 02:07:08 PM
I'm glad you're back Sandman! You have been missed.
Title: Re:Is there a way to check for memory leaks?
Post by: Sandman on August 18, 2012, 09:24:29 PM
Ha thanks guys. :) I don't have much time these days... graduating and currently doing an internship at Qualcomm in Silicon Valley. :)
Title: Re:Is there a way to check for memory leaks?
Post by: josebita on August 18, 2012, 11:24:45 PM
Quote from: Sandman on August 18, 2012, 09:24:29 PM
Ha thanks guys. :) I don't have much time these days... graduating and currently doing an internship at Qualcomm in Silicon Valley. :)
Welcome back :)
Title: Re:Is there a way to check for memory leaks?
Post by: handsource-dyko on August 19, 2012, 09:27:47 AM
So, you left Enschede? I live the neighbouring town and visit Enschede regularly to visit the gamestore for some old skool hardware and games.
But Are you designing smartphone chips now? Like the Qualcomm snapdragon? Or are you doing software projects?
Title: Re:Is there a way to check for memory leaks?
Post by: Sandman on August 20, 2012, 06:58:06 AM
Ah, cool you are so close to my university. :-) I'll be back there in December or January, finishing my final project.

At Qualcomm I'm developing a high-performance framework for the Snapdragon. This sounds awfully generic, I know, but can't really talk much about it. :-)
Title: Re:Is there a way to check for memory leaks?
Post by: handsource-dyko on August 30, 2012, 06:14:04 PM
Just a quick question about memory managment: I've got my malvado demo mode now completed, and I was thinking that I've got a memory leak somewhere in my game. But after some testing I found out that the memory usage increases to a certain amout (70 mb tops) and then suddenly drops to a very small amount after about 30-45 minutes whilst doing practically the same stuff. I know bennu doesn't have garbage collecting, but I wonder if there is some kind of caching going on.

Is windows slow with memory de-allocation or is it buffering memory? I find it remarkable, since I normally do short test runs and today I was running the demo for a longer time, and in two test sessions I did I noticed this behaviour while watching bgdi's memory usage in the task manager.
Title: Re:Is there a way to check for memory leaks?
Post by: Sandman on September 02, 2012, 05:07:45 PM
Yeah I'm not sure if you can trust Task Manager. And maybe Windows does what you say, not sure of that. You could try running on Linux and see what the results are there.
Title: Re:Is there a way to check for memory leaks?
Post by: handsource-dyko on September 02, 2012, 06:13:33 PM
I have explained the problem in a seperate topic on some more detail: http://forum.bennugd.org/index.php?topic=3192.0 (http://forum.bennugd.org/index.php?topic=3192.0)
Because I felt it desevered it's own topic.