Jump to content

April 2017 »

23 24 2526272829

Recent Entries

Recent Comments

Latest Visitors

- - - - -

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

C# SlimDX DirectX 11 Memory
4: Adsense

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…
Posted Image


Dec 13 2013 08:39 AM

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

Dec 13 2013 11:47 AM

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

Note: GameDev.net moderates comments.