View Full Version : Problem with texture allocation

03-20-2014, 09:44 AM

In a project, I need big and precise texture data. A full data set is made of :

- a texture 2D, RGBA32f, 4096x2048, no mipmaps => about 128 Mo
- a texture 3D, RGBA32f, 1024*1024*8, no mipmaps => about 128 Mo

My video card is a GTX 780 TI with 3 Go RAM

When my application startup, GPU-Z shows about 300 Mo used on GPU

Then I load a data set => ok, GPU-Z shows about 600 Mo used (which seems correct)

Then I unload the dataset => ok, GPU-Z shows about 300 Mo used (which seems correct)

Then I load a new dataset => ko, it fails about every time, with "OpenGL out of memory" error

I can't believe there is not enough free contiguous memory on my 3Go card...

Does anyone have any advice on how to debug this ?

Thanks !

Ilian Dinev
03-20-2014, 01:38 PM
Try glFlush and such. Or try to reuse the names, generated from glGenTextures. Do you happen to use glTexSubImage and such to often modify the textures?

03-20-2014, 02:58 PM
I've already done the following :

New data set is loaded right after previous one is released.
The new data set may vary (a little) in size from previous one (but always POT), so I have to re-allocate the textures.
I reuse the names generated from glGenTextures.
I've added glFinish after the texture release.

Results vary from different applications run :

- sometimes I can load/unload the dataset about 10 times without error
- sometimes I can load/unload the dataset only once without error

I really don't understand where is the problem : even by looking at GPU Z, ram usage increase and decrease as expected between every load / unload, but sometimes re-allocation (even with exactly the same size) fails.

Another (maybe) important point : it is a win32 application and the OpenGL contexts are shared between multiple OpenGL widgets (but the problem appears also with a single widget displayed)

03-20-2014, 02:59 PM
And, to answer your question, no the data are not modified, I upload them only once, just after texture allocation.

03-20-2014, 04:48 PM
Is this a 32-bit program? You may not be out of memory on your GPU but you may well have exhausted address space in system RAM, so you should be measuring that too.

03-21-2014, 12:44 AM
Yes, this is a 32-bit program, but the process RAM usage is about 600-700 Mo, so his should not be a problem I think.

03-26-2014, 01:00 AM

I've rebuilt the whole solution as a 64 bits application, and I looks like I don't have texture alocation problems anymore !

Thanks for your help, and I note for myself : "always build 64 bits applications, this often works better"