Is there a way to check for memory leaks?

Started by MisterN, April 14, 2012, 05:14:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

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.
werg

handsource-dyko

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.

BlackCurtain

I always unload stuff I don't need at the end of a process below
onexit

Sandman

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
-- Sandman

handsource-dyko


Kloppix

I'm glad you're back Sandman! You have been missed.

Sandman

Ha thanks guys. :) I don't have much time these days... graduating and currently doing an internship at Qualcomm in Silicon Valley. :)
-- Sandman

josebita

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 :)

handsource-dyko

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?

Sandman

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. :-)
-- Sandman

handsource-dyko

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.

Sandman

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.
-- Sandman

handsource-dyko

I have explained the problem in a seperate topic on some more detail: http://forum.bennugd.org/index.php?topic=3192.0
Because I felt it desevered it's own topic.