Sign in to follow this  

Memory usage going through the roof (fix)

This topic is 2397 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 [img]http://public.gamedev.net/public/style_emoticons/default/rolleyes.gif[/img]

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 [img]http://public.gamedev.net/public/style_emoticons/default/ohmy.gif[/img]

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

This topic is 2397 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this