Should framebuffer allocation use this much memory

I’m using GLX on linux to create OpenGL context. When doing memory profiling the glXChooseFBConfig function that I use to get the list of frame buffers seems to take ~330Mb of memory. I call it like this GLXFBConfig *fb = glXChooseFBConfig(display, XDefaultScreen(display), fbAttributes, &fbCount). Create context. And then free memory with XFree(fb).

Is this normal? Should framebuffer allocation use this much memory?

  • Are you talking CPU memory or GPU memory? The former suggests CPU. The latter suggests GPU.
  • How are you checking for how much CPU (or GPU) memory is allocated before/after the framebuffer allocation?
  • How are you separating this out from other allocations for basic context init?
  • Which GPU/graphics driver are you running?

Memory pooling is the first thing that comes to mind. Just because inner allocations are freed doesn’t mean the outer memory pool block allocs have been released back to the OS.

How OpenGL implementations manage memory is going to be very implementation-dependent. The OpenGL spec makes virtually no guarantees about memory aside from some cases where a GL_OUT_OF_MEMORY error may be raised.

You should never get the impression that there is an exact one-to-one correspondence between memory requirements and memory allocated. This is as true of your OpenGL implementation as it is of your OS. It’s not 1973 any more.

With that in mind, it’s perfectly legal for an OpenGL implementation to allocate any arbitrarily-larger block of memory than what is required. If we assume that allocating memory is potentially a slow and expensive operation, whereas just drawing down from already allocated memory is fast (both reasonable assumptions) this makes perfect sense. The implementation can use it’s own internal heuristics to determine that once you’ve created your context, on average you’ll need an initial block of ~300mb, and just allocate it up-front so that it’s already there and available when the time comes that you do need it. And that’s a perfectly reasonable thing to do, and highly desirable under most common circumstances.

Thanks for the reply!

  • I have integrated graphics card so the shared memory?
  • I’m checking the allocated memory of current process by parsing /proc/self/status.
  • I removed the code for context creation and only left the glXChooseFBConfig method.
  • Integrated Intel graphics card

What is the memory pool used for? Is it used only for the storage of the default framebuffer and context(?), or also storage of shaders and data buffers?

Thank you!

And I’m guessing the initial block of memory that it allocates, it then uses to store other GPU related data, like shaders and data buffers?

Shaders typically require virtually no memory. We’re talking kilobytes.

Other GPU objects that can require significant memory would include buffer objects and textures.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.