windows memory managment and the taskmanager

Started by handsource-dyko, August 31, 2012, 03:07:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

handsource-dyko

I noticed something interessting with it's memory usage when running malvado with demo for a good length of time. In the windows task mangager I always check occasionally how much memory it's using, and if I run it for a short time (about 10 minutes or less) the memory use is increasing and I was under the impression that I have a memory leak somewhere.

But now I've run the demo for a few longer sessions (today for a couple of ours straight) and I noticed that the memory usage increase stops at around 65-70mb, and then drops to about 12mb after about 30-45 minutes. From that time on the memory usage varies between about 12mb - 18mb. The attractmode runs 5 different level demos, and use the actual game engine. What I find strange is how bgdi/malvado initially needs about 70mb and later only about 18mb for doing the same thing over and over.  It looks like a sawhtooth pattern almost if you where to draw it on a graphpaper.

Now I wonder if windows' taskmanager gives a representive figure on the acutal memory use. I've read somewhere http://stackoverflow.com/questions/131303/linux-how-to-measure-actual-memory-usage-of-an-application-or-process that the ps command in linux doesn't show the correct figure in all cases. I'm under the impression that windows reserves a rather large chuck of memory and then decides to free a large part of it to a size more in line with the programs actual memory usage.

Can someone explain this phenomenon or has similair experiences? I find it quite strange and it learned me that you need to run a program for a couple of hours if you want to know if there is a memory leak or not. Just doing this test made me rule  out the likeness of a memory leak.

O btw,  the demo runs pretty well and is very stable. :) I fixed a really hard bug with jumping on platforms and now it's working nicely. There are a few small minor things but those are not really worth fixing right now.

SplinterGU

#1
you generate a stub binary? I mean, you compile with -s? or/and with -a?
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

handsource-dyko

#2
Yes, always. Common practice for me so that I can use the debug window (I also do this for DoctrorN's projects). I know it's not really needed for the game, but for the editor it's handy. I like the use of the Alt-X as panic button.

SplinterGU

don't use -a and -s if you want reduce the memory use...

when you use -a and -s you create an executable that is very huge, this executable is loaded by the SO in memory... then you use 80mb or more when you start it...

I suggest you that you use only -a for dcb, but no add it to executable.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

handsource-dyko

Ok. Thanks. I never realised that the debugger would add so much memory overhead. Well for the editor it's not really a big issue for me since it only has to run on pc's and they have plenty of memory these days, but with the game itself I'll defenitly take it into account because I challange myself to make malvado more efficient in relation to it's content size.

I want to rewrite the editor and the level rendering part to make it more efficient in disk size and memory usage. Right now I have two editors side by side, one for designing the backgrounds and hardness maps, and the main editor to place the enemies and the rest. I have plans to combine them into one (also the data structures), and the game engine can benefit from this (in the future).

But, I am doing this graduatly, it's just a part of an ongoing refactoring and maintance process. The new demo implementation is the third (and final) implementation of the demo mode in malvado. I have wanted to it this way the first time but for practical reasons I implemented it in an easier way (with screendumps) first. Now it's exactly the way I like it: small in disk and memory usage, and using an old skool method.  ;D But It took some time to cook.

SplinterGU

no, no debugger...

I mean, add all resources (graph files+sounds+other files) to dcb, and add dcb to .exe.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

handsource-dyko

Oh, no I don't usually add resources to the dcb. I'll keep them seperate.

SplinterGU

then I don't know why you consume 80mb of ram...

sorry for the misunderstanding...
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

handsource-dyko

I compiled without any options now (also without debugger) and I still get the same behaviour oddly enough.

SplinterGU

no bennugd issue... or you code do something with memory or windows issue...

try with a hello world in bennugd.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

handsource-dyko

In linux my program behaves differently. There it seems to leek memory, and after more then an our it's using 200+ mb of ram. In windows the memory drops after some time, but in linux it doesn't seem to do that. Quite strange this difference.

In windows I'm using version 1.00 jul.9, 2012 and in linux version 1.00 jan. 20, 2011.
Malvado uses the let_me_alone function in it's main routine, to keep one the main control process alive. I've checked if I haven't forgotten any fpg unloads, but these and other resources seem fine in that aspect.

handsource-dyko

I noticed something funny today: If you minimize and then maximize the bgdi application window, I see the memory usage in the taskmanager change for 200mb (or any high number) to only a few megabytes. I am thinking that the windows task manager (but also top and ps and the gnome task monitor) are not showing the actual memory usage properly. It almost looks like that they count the memory over the runtime and only refresh the number when you minimize and maximize a window a few times rapidly.