Archived

This topic is now archived and is closed to further replies.

MatrixCubed

Memory optimization... by accident?

Recommended Posts

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

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites