Jump to content
  • Advertisement
  • entries
  • comments
  • views

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

Sign in to follow this  


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

Sign in to follow this  


Recommended Comments

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

Share this comment

Link to comment

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

Share this comment

Link to comment

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

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!