PDA

View Full Version : Frequent GL_OUT_OF_MEMORY errors



JoshKlint
09-13-2014, 09:36 AM
I am frequently experiencing GL_OUT_OF_MEMORY errors with my application. GPU Shark says my available VRAM is 1536 mb, but I can get this error when only 389 mb are in use.

Is video memory fragmentation really a problem? This seems really odd.

I have Steam open at the same time, and cannot easily disengage it from my application.

JoshKlint
09-13-2014, 11:31 AM
I should also note I am creating a 4096x4096 red float texture during the loading, which uses 67108864 bytes (64 mb).

Nikki_k
09-14-2014, 03:26 AM
Running out of memory can also mean running out of address space. With 32 bit under Windows, for example, your application's entire address space is 2GB, and once that's used up anything can produce an out of memory error.

So for further investigation you need to tell us something about the system this happens on.

JoshKlint
09-15-2014, 01:42 PM
Running out of memory can also mean running out of address space. With 32 bit under Windows, for example, your application's entire address space is 2GB, and once that's used up anything can produce an out of memory error.

So for further investigation you need to tell us something about the system this happens on.
The application in question is 32-bit. However, I am well below the 2 gb limit of 32-bit applications.

malexander
09-15-2014, 04:18 PM
You can still run into memory fragmentation issues with 32b Windows, even if you're shy of the 1GB mark. We found that the address space randomization feature in more recent Windows version made this situation worse (with similar allocation sizes). The problem is that there isn't a contiguous free range of memory large enough for your request. We had to break up these large arrays into smaller sub-arrays in order to workaround the problem (and eventually just dropped 32b altogether for 64b Windows).

Try creating the texture without uploading any data to it (glTexImage2D(GL_TEXTURE_2D, ... NULL)) and then use several glTexSubImage2D() calls with smaller arrays to fill in the data. If that works, it would at least tell you if memory fragmentation is to blame. It may a failure to allocate a buffer in system memory that's temporarily storing the texture data before sending to the GPU.

JoshKlint
09-16-2014, 03:55 PM
You can still run into memory fragmentation issues with 32b Windows, even if you're shy of the 1GB mark. We found that the address space randomization feature in more recent Windows version made this situation worse (with similar allocation sizes). The problem is that there isn't a contiguous free range of memory large enough for your request. We had to break up these large arrays into smaller sub-arrays in order to workaround the problem (and eventually just dropped 32b altogether for 64b Windows).

Try creating the texture without uploading any data to it (glTexImage2D(GL_TEXTURE_2D, ... NULL)) and then use several glTexSubImage2D() calls with smaller arrays to fill in the data. If that works, it would at least tell you if memory fragmentation is to blame. It may a failure to allocate a buffer in system memory that's temporarily storing the texture data before sending to the GPU.

That's interesting. So GL_OUT_OF_MEMORY can signify:

The GPU VRAM being filled up (which is not the case here).
The GPU lacking a continuous block of memory of the requested size (which is very unlikely to be the case).
System memory lacking a continuous block of memory for some operation (which seems more feasible).


I have noticed a lot of malloc fails in the past with Windows 8. I actually allocated a static texture buffer for this reason...