Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libGL heap usage

I am working on a linux-based c++ OpenGL application, utilizing the Nvidia 290.10 64bit drivers. I am trying to reduce its memory footprint as it makes use of quite a lot of live data.

I've been using valgrind/massif to analyze heap usage, and while it helped me optimize various things, by now the largest chunk of heap memory used is allocated by libGL. No matter how I set the threshold, massif doesn't let me see in detail where those allocations come from, just that it's libGL. At peak times, I see about 250MB allocated by libGL (out of 900MB total heap usage). I hold a similar amount of memory on the graphics card, as VBOs and Textures (mostly one big 4096*4096 texture).

So it appears as if a similar amount of memory as what I upload to GPU memory is allocated on the heap by libGL. The libGL allocations also peak when the volume of VBOs peaks. Is that normal? I thought one of the benefits of having a lot of GPU memory is that it keeps the RAM free?

like image 731
pholz Avatar asked May 22 '12 08:05

pholz


1 Answers

What you experience is perfectly normal, because a OpenGL implementation must keep a copy of the data in system memory for various reasons.

In OpenGL there's no exclusive access to the GPU, so depending on its use, it may become neccessary to swap out data (or just release some objects from GPU memory). Also GPUs may crash and drivers then just silently reset them without the user noticing. This too requires a full copy of all the buffer data.

And don't forget that there's a major difference between address space allocation (the value reported by Valgrind) and actual memory utilization.

like image 128
datenwolf Avatar answered Oct 12 '22 15:10

datenwolf