Memory optimization... by accident?

Started by
2 comments, last by MatrixCubed 21 years, 10 months ago
I was monitoring my game''s memory usage, which spiked to 10 mb when the game is first launched. This peaks around 10mb. Then I tried minimizing the game, and the memory usage goes down to around 1.2mb... not bad. Remaximizing, however, only adds about 300kb to that, for a total of around 1.5mb when re-maximized. Toggling between the two then shows a range of memory use between 800kb (lowest) and 1.5mb (highest). Resolution is 1024x768x16bpp, in a windowed (non-fullscreen) app. And I have only allocated memory enough for about 450kb worth of textures. I really don''t know what the difference would be. I have added a WM_ACTIVATE message handler that bypasses the rendering loop, but I am not deallocating anything or doing anything special other than the bypass -- a simple "if (bActive) { Render(); }. I am using pure OpenGL, no additional OGL libraries such as GLUT. No DirectX objects either, it''s mostly a straight OpenGL-meets-Windows application at this point. So what''s the deal with the sudden memory savings? Is it just Windows 2000 Pro''s way of maintaining the application''s footprint? Obviously I am not complaining at this oddity, but I would like to understand what''s going on under the hood. MatrixCubed
http://MatrixCubed.cjb.net
Advertisement
I''ve had something similar happen to me. This is what I think happens, but I could be totally wrong. Your program is allocating a bunch of memory at startup, loading stuff in using temp buffers and such, and then once it up and running it stops using all this. This could be the code you made yourself, or it could be some over head of programming in Windows/C++/what have you. But Windows doesn''t realize, or care, that theres all this unused memory. When you minimize it, then the built in garbage collector comes in and cleans up all that unused memory, leaving you with what your program is really using (or maybe its just the references aren''t updated in the task manager, so it thinks you''re still using that memory, while windows itself knows you''re not). The same thing happens when you leave your program running for a long period of time because the collector goes around and cleans stuff up every once in a while. I''m thinking it might run when you start a new program too, but I''m not sure. Again, I have no idea if anything just said is true, but its what I like to believe happens...

--Buzzy
(formerly buzzy_b)
if it''s a debug build microsoft put in a whole bunch of crap you dont need into the executable to monitor it for bugs and undesirable stuff...

do you still get the same problem with a release build?

thanks

-jonnii
-jonnii=========jon@voodooextreme.comwww.voodooextreme.com
most likly its just paged out memory that does not need to be in phsycal ram. things like your system memory copy of textures will be stored in the swap file. also quite likly that you may have memory leaks in your windows code. ie loading images using hbitmaps but not deleting things properly when done with it.

This topic is closed to new replies.

Advertisement