Jump to content
  • Advertisement
Sign in to follow this  
malborojones

Memory usage going through the roof (fix)

This topic is 2614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Haii rolleyes.gif

I'd been wondering all day while debugging my program why after about 20 seconds the frame rate was dropping to about 10 fps. Anyway I ran a release and it was staying at a constant 60fps like I'd asked DX to do so I went to make a cup of tea and left it running just to make sure. I got back and my computer had completely frozen ohmy.gif

So once I managed to exit it I run it again and watched the task manager and noticed that the memory usage of my app was increasing by about 30K a second! So after a little fiddle I found the cause of the problem, I have a "draw all sprites" function I call before rendering, in this function I was retrieving sprites from a list one by one into a temporary sprite and drawing them. Now what I hadn't realised is that although after the function was complete the sprite was lost, I presumed that it would free up the memory it used (I was wrong obviously)

So if anyone has this problem, to fix all you need to do is call your LPD3DXSPRITE::Release() and it will stop gathering in the memory. This is true also for textures as I had to release them too to stop it increasing at all. (and probably for 3D resources too, if anyone wants to confirm that)

Thought that might help someone googling one day because I was stumped for about an hour ^_^

Share this post


Link to post
Share on other sites
Advertisement
In general, any time you call a D3DXCreate.., device->Create.., or device->Get... function, check the interface for the created object (sprites, textures, vertex buffers, etc.) for the following functions:

OnLostDevice()
OnResetDevice()
Release()

and call these functions appropriately within your game loop.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!