Frequent GL_OUT_OF_MEMORY errors

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.

I should also note I am creating a 4096x4096 red float texture during the loading, which uses 67108864 bytes (64 mb).

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.

[QUOTE=Nikki_k;1261636]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.[/QUOTE]
The application in question is 32-bit. However, I am well below the 2 gb limit of 32-bit applications.

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.

[QUOTE=malexander;1261678]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.[/QUOTE]

That’s interesting. So GL_OUT_OF_MEMORY can signify:
[ul]
[li]The GPU VRAM being filled up (which is not the case here).[/li][li]The GPU lacking a continuous block of memory of the requested size (which is very unlikely to be the case).[/li][li]System memory lacking a continuous block of memory for some operation (which seems more feasible).[/li][/ul]

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