locked
How do I deal with Out of Memory errors and such in Direct2D? RRS feed

  • Question

  • How do I deal with Out of Memory errors and such in Direct2D?

    I need to deal with these properly so my app doesn't crash.  My app, not a game but uses Direct2D, crashes every once in a while due to out of memory errors and other Direct2d errors.  Now I do catch the errors in the C++/CX side but it still is crashing.  So what do I do if it say gets an Out of Memory error in my BeginDraw or EndDraw function?  How do I deal with resetting everything and not getting the app to crash?

    Sorry I'm only a year and a half into Direct2D programming and don't know how to deal with this properly.


    SB Software Developer

    Wednesday, January 22, 2014 11:51 PM

All replies

  • You'd handle it the same as in any other app.

    Determine what resource you are running out of. Try to reduce the usage and find and eliminate any leaks. If you still run into the error you'll need to reduce usage and try again (or not).

    Try to reproduce under a debugger or let it crash and examine a crash dump, though that won't capture video memory.

    --Rob 

    Thursday, January 23, 2014 4:20 PM
    Moderator
  • Well unfortunately I must use the entire texture size on some refreshes.  I have a Render function that I wrote that renders the graphics.  I am wondering if this maybe gets called twice and this is causing it. 

    I have it "Locking" the multithreading process at the beginning of my BeginDraw and EndDraw functions but maybe should I lock it at the beginning of my Render function?  The Render function calls the other two.

    Also how, when and should I be using the ->ClearResources(0) method?


    SB Software Developer


    • Edited by Sacha Bwin Friday, January 24, 2014 1:40 AM clarity
    Thursday, January 23, 2014 11:43 PM