- Home /
How do you check texture memory usage?
We have a stand alone build utility that allows a user to bring up multiple images from their hard drive in to 3D space. Unity3d 3.5.6 is crashing due to running out of texture memory. I'd like to do a simple process of checking for enough free texture memory before trying to load another image. Or at the very least, if we reach a certain amount of usage (like 80%), pop a message instead of throwing a C++ exception in to the output.log file and failing silently.
DynamicHeapAllocator out of memory - Could not get memory for large allocationCould not allocate memory: System out of memory!
Trying to allocate: 178956976B with 32 alignment. MemoryLabel: Texture
Allocation happend at: Line:345 in C:/BuildAgent/work/14194e8ce88cdf47/Runtime/Graphics/Texture2D.cpp
Internet searches are not turning up any way for me to correctly code around this problem. :( Since the user can bring up any arbitrary image, simply limiting the number of images won't be good enough. (though it looks like at this point, my only chance of avoiding the issue as much as possible)
System.GC.GetTotalMemory is not proving useful.
I need to intelligently avoid the problem with code, or be able to catch the exception and then continue on.
Thoughts? Suggestions?
Oh, and yes, I have the "LoadImage" section wrapped in a C# try->catch block, which has no effect.
If I am running in the editor, the editor crashes. If I am running in a stand alone build in Windows, the app continues, but it won't load any more images. (just this giant red question mark with a white background)