Finding the maximum video memory...

Hello folks,
i’m new in this forum and i would like to ask you a question.
How do i figure the amount (in bytes?) of the available video memory (for texturing) through OpenGL api? is there an extension i can query for its value or some other method other than “test and fail”?

I looking for something very similar to ‘AvailableTextureMemory’ in DirectX Device object.

thanks a lot :slight_smile: ,


  • It’s a window system/platform specific thing, which generally doesn’t belong in GL
  • The concept of ‘video memory available for texturing’ doesn’t really mean anything on some platforms or GPUs, especially systems with shared memory. (which is why the first point is important).
  • What number do you actually want, the size of VRAM (assuming it exists), or the size you can use? What if the size you can use is variable? What if another hungry program is running? What if that other hungry program isn’t running yet.
  • Even ‘test and fail’ doesn’t work. Some platforms virtualize VRAM, and will happily let you continue to create textures until your flat-out out of system memory (or even 2-4GB worth on a 32-bit system).

Allocate what you need, and give your user a quality slider. Otherwise, you’ll need to resort to platform specific methods outside of GL.

For optimazation purposes I have resorted to a hybrid approach. I know the target platforms that my application will run on. Currently our company ships a handful of systems. For those systems, I know the VRAM and have built that into my software. The software recognizes the graphics card and gets the VRAM. If the system is not recognized, I rely on GL to tell me if texture creation is successful. This allows us to run on a future system until we benchmark it like the others.

Under Windows, you can read the total amount of video memory in the registry.

Step 1: go in HKEY_LOCAL_MACHINE/HARDWARE/DEVICEMAP/VIDEO and find the device key matching your video card, for example \Device\Video0. The string contains a path to the registry.

Step 2: Go to that path. Find the key called “HardwareInformation.MemorySize”. It contains the binary representation of the amount of VRAM.

There’s of course no guarantee it’ll always work, especially in the case of non ATI / Nvidia video cards.

there really should be a way of getting the total amount of physical server memory (ie the amount of memory at the server end of the bus), irrespective of whether it’s available for allocations or not. This gives you an idea of the type of hardware you’re running on, and you know that any performance problems the user experiences are due to the user not running your application in exclusion to all others. If you’re running a game or simulation at the same time as autocad then you’re on your own and I should not have to allow for that while I’m trying to do very complicated things in real time. When I can’t create a texture, for example, I will error out with an assert and give you a stern talking to.
I know for a fact that this would have been useful information for the last 7 years of applications I’ve written. Yet we all silently accepted that in anything but normal circumstances, the number would be meaningless because of virtualised memory models, unified memory architectures etc.etc.blah.blah. But really we all knew our software would be: the main application running and running on a very limited range of hardware (nvidia,ati,3dlabs,intel);

Originally posted by knackered:
If you’re running a game […] at the same time as autocad then
…then you could probably get fired :stuck_out_tongue:

To continue the platform-specific examples, on Mac OS X you can query the amount of VRAM on a given renderer via CGLDescribeRenderer(…, kCGLRPVideoMemory, …)

It’s up to you to iterate over all the available renderers and use them appropriately.

Nice, looks like on the Mac you can get some specific info…/reference.html

on Windows, moti already mentioned how it’s to be done --> DirectDraw
There is not extension for this for GL.

I’ve been working on a System Identification library for a while, and although progress is slow, it currently abstracts the required calls on Windows (XP), and allows you to get this info easily. Please feel free to give it a try and see if it’s something you could use.


got pretty much everything wrong for my system.

Got everything correct except it says

Model: AMD Athlon (Model 4 - 0.18 â•¡m and 256-KB L2 cache

L1 Cache size: 64 KB
L2 Cache size: 512 KB

thank you all for your replies.
that helped me a lot and gave a general idea about things.

Just to sum up, with regard to what is done today and what isn’t i think it would be very nice to probe this information through OpenGL (i still think OpenGL should be the origin for this information).
Maybe in future version of GL.
So currently i need to have information per device/hardware.

To frogblast, that is what i meant, i want to know the size of VRAM to perform some benchmarking tests over the hardware knowing that the numbers i’l get are relevant to textures stored in the closest memory to the GPU.

The most important platform for me is linux/unix. It is almost obvious to me (right now) that on windows i’ll use DX and not GL.

Thanks guys :slight_smile: ,

It’s a nice program. Benchmark soft need that kind of detail but for general apps/games, it’s not needed so it need not be part of GL. However, it nice to have like the API available for OSX

Originally posted by knackered:
got pretty much everything wrong for my system.
Quite the opposite here, except the VRAM size was reported as -1MB. What an irony :stuck_out_tongue: