Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.






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

Posted by ericrrichards22, 13 December 2013 · 396 views

C# SlimDX DirectX 11 Memory
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

Read More...




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

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

November 2014 »

S M T W T F S
      1
2345678
9101112131415
16171819202122
232425 26 272829
30      

Latest Visitors

PARTNERS