OutOfMemoryException - Eliminating Temporary Allocations with Static Buffers in Effect Wrapper Code

Published December 13, 2013
Advertisement
I came across an interesting bug in the wrapper classes for my HLSL shader effects today. In preparation for creating a class to represent a game unit, for the purposes of demonstrating the terrain pathfinding code that I finished up last night, I had been refactoring my BasicModeland SkinnedModel classes to inherit from a common abstract base class, and after getting everything to the state that it could compile again, I had fired up the SkinnedModels example project to make sure everything was still rendering and updating correctly. I got called away to do something else, and ended up checking back in on it a half hour or so later, to find that the example had died with an OutOfMemoryException. Looking at Task Manager, this relatively small demo program was consuming over 1.5 GB of memory!

I restarted the demo, and watched the memory allocation as it ran, and noticed that the memory used seemed to be climbing quite alarmingly, 0.5-1 MB every time Task Manager updated. Somehow, I'd never noticed this before... So I started the project in Visual Studio, using the Performance Wizard to sample the .Net memory allocation, and let the demo run for a couple of minutes. Memory usage had spiked up to about 150MB, in this simple demo that loaded maybe 35 MB of textures, models, code and external libraries...
memprofiling_thumb%25255B1%25255D.jpg?imgmax=800

Read More...
0 likes 2 comments

Comments

a_insomniac

Interesting blog posting Eric. I am an Escalation Engineer for Micro Focus and we have a product called DevPartner Studio. Customers that report issues like the one in your blog post take advantage of our tool and use a component called "Memory Analysis". It is a real time memory tool for the .NET framework. Check it out if you like ... I'm not in sales just pointing it out to you smile.png http://www.borland.com/products/devpartner/read/

That said, talk about fortuitous luck to have been called away and then discovered you had this issue. Most of the time during testing, who actually leaves the compiled code running for more than 10 minutes a stretch smile.png

December 13, 2013 02:39 PM
ericrrichards22

@a_insomniac -

I tried the trial version, but it doesn't seem to support VS 2013. I've got MSDN, but I rather like 2013, and am not really eager to go back to 2012.

It was a lucky find...

December 13, 2013 05:47 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement