XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

XBOX Out of memory exception on texture2D load

Last post 28/06/2009 15:09 by UberGeekGames. 4 replies.
  • 28/06/2009 5:38

    XBOX Out of memory exception on texture2D load

    I am getting a pesky out of memory exception and wanted to see if anyone had any ideas of why it might be happening.

    The exception is happening when I try to load a fairly large texture 1600x1600 and only happens when in the XBOX version of my project.

    I have used System.GC.GetTotalMemory and the XNA Framework Remote Performance Monitor to verify that I only have about 7MB of memory allocated at the time I am trying to load the texture.

    The code for loading the texture is nothing fancy:
    bigLevelMap  = content.Load<Texture2D>(levelMapName);

    I am using multi-threading to display a loading screen so that the loading can happen in the background but I have verified that the Out Of Memory exception occurs when I disable this multi-threading code.

    Previous to loading this texture I have pre-loaded many smallerish textures (maybe around 400?) Most of these texures are being held in DXT format. As far as I know I can't use DXT compression for this texture because I need to read data from every pixel.

    I also create some rendertargets for things like shadows etc. I notice that if I cut down the size of my render targets and/or disable MSAA then I don't get the out of memory exception.

    From all of this it seems as though I am running out of video memory. But it was my understanding the the XBOX has shared 512MB for video and main memory.
    It makes sense that GC.GetTotalMemory and even the Performance Monitor wouldn't be able to see how much video memory I have allocated.

    Later on in my game I have over 30MB of memory allocated, so it doesn't make sense that I get an out of memory exception when I only have 7MB allocated...

    Any ideas how to solve this?


  • 28/06/2009 5:52 In reply to

    Re: XBOX Out of memory exception on texture2D load

    The only thing I could find on this was this post here where ShawMishrak seems to indicate that you shouldn't see the message if you're not running in debug mode with show all exceptions on. Does this occur in your release version as well? Or is it as he describes only when debugging and when you have those options turned on in Visual Studio to show all exceptions?
  • 28/06/2009 7:37 In reply to

    Re: XBOX Out of memory exception on texture2D load

    Oh it's definitely a problem in Release mode. In release mode it crashes my nice XNA Game Studio Connect... unless there is a way to "Catch" an OutOfMemory exception and keep on working as if nothing happened. :-)
  • 28/06/2009 14:54 In reply to

    Re: XBOX Out of memory exception on texture2D load

    Sounds like you're getting a different issue then. Hopefully someone else can chime in with something useful. If you make the texture smaller do you still get the issue?
  • 28/06/2009 15:09 In reply to

    Re: XBOX Out of memory exception on texture2D load

    You may very well be running out of VRAM or one of the other Xbox texture memory buffers (maybe Shawn can pop in and correct my throwing around of these terms? ;-) )
    At any rate it sounds like it's a hardware problem, so you'll need to work around it and use less memory.
    Is it possible you could disable MSAA until you're done loading and see if that helps?
    What is the texture being used for? Maybe you could split it into smaller textures and load the one that you currently need?
    "No programmer can pick up a TV remote without thinking what it would take to add a stun gun. [...] Their motto is 'if it ain't broke, it doesn't have enough features yet'" - Scott Adams, The Dilbert Principle

    The signature that was too big for the 512 char limit
Page 1 of 1 (5 items) Previous Next