Wednesday, July 15, 2015

opengl - How can I tell how much video card memory I'm using?


I want to programmatically determine at runtime how much video card memory is being used by my program. Specifically I'm wondering about how to do it on a Windows machine using OpenGL, but am interested of ways to do it on other platforms as well.


I know there are utilities out there that will show me the memory usage as my program is running, but I want to be able to query that information from my code.



Answer



You can find the video memory of an Nvidia card using the NVX_gpu_memory_info extension, or an ATI card using ATI_meminfo. Here is a snippet of code I found which might get you started.




However, Paul Nettle at flipcode wonders why one would want to find the available video memory, saying:



The reason it's difficult (and sometimes impossible) to determine the amount of video memory is very similar to the reasons why OpenGL won't let you lock the frame buffer and access it directly.




And goes on to explain, in essence, that an "amount of video memory" might not actually mean anything. I concur with him on the reasoning that, for example, the amount of "free" memory in a Windows Vista/7 machine is irrelevant; hopefully there is no free memory, because free memory is wasted memory. But there is always some areas of memory dedicated to caches which are cleared by Windows, should an application need them.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...