Amount of VRAM on PC Windows

Hi all,
I’m looking for a way to get the amount of VRAM of a PC running Windows.
SPDisplaysDataType is my friend on Mac, but I don’t find the solution on Windows, even with MBS plugins.

Thanks for your help.

Jean-Luc

You can get it from the registry.

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class{4d36e968-e325-11ce-bfc1-08002be10318}\

There will be subkeys (folders) enumerated for each gpu on the system, beginning with 0000.

Inside there, you can read the HardwareInformation.qwMemorySize binary key to get the VRAM amount.

So for the first GPU on the system, the full key path would be HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class{4d36e968-e325-11ce-bfc1-08002be10318}\0000\HardwareInformation.qwMemorySize

On some systems, you may not find qwMemorySize, in that case, get the value from MemorySize, which is used to hold values with a max of 4GB. qwMemorySize is a Quad Word value so it can hold the larger values.

In addition to Christians solution, here is another way to get the information through declares:

Sub Pressed() Handles Pressed
  Declare Function GlobalMemoryStatusEx Lib "Kernel32.dll" (ByRef lpBuffer as MemoryStatusEx) as Boolean
  
  Var MyMem as MemoryStatusEX
  MyMem.dwLength = MyMem.Size
  Var Result as Boolean
  Result = GlobalMemoryStatusEx(MyMem)
  
  TextArea1.Text = "Total physical memory (MB): " + CStr(MyMem.ullTotalPhys/1024/1024) + EndOfLine
  TextArea1.Text = TextArea1.Text + "Available physical memory (MB): " + CStr(MyMem.ullAvailPhy/1024/1024) + EndOfLine
  TextArea1.Text = TextArea1.Text + "Total Virtual memory (GB): " + CStr(MyMem.ullTotalVirtual/1024/1024/1024) + EndOfLine
  TextArea1.Text = TextArea1.Text + "Available Virtual memory (GB): " + CStr(MyMem.ullAvailVirtual/1024/1024/1024) + EndOfLine
  TextArea1.Text = TextArea1.Text + "Total Page File (MB): " + CStr(MyMem.ullTotalPageFIle/1024/1024) + EndOfLine
  TextArea1.Text = TextArea1.Text + "Available Page File (MB): " + CStr(MyMem.ullAvailPageFile/1024/1024) + EndOfLine
  TextArea1.Text = TextArea1.Text + "Available Extended Page File (MB): " + CStr(MyMem.ullAvailExtendedVirtual/1024/1024) + EndOfLine
  TextArea1.Text = TextArea1.Text + "Memory Load (%): " + CStr(MyMem.dwMemoryLoad) + EndOfLine
End Sub

Here is the structure:

Structure MemoryStatusEX
  dwLength as UInt32
  dwMemoryLoad as UInt32
  ullTotalPhys as UInt64
  ullAvailPhy as UInt64
  ullTotalPageFIle as UInt64
  ullAvailPageFile as UInt64
  ullTotalVirtual as UInt64
  ullAvailVirtual as UInt64
  ullAvailExtendedVirtual as UInt64
End Structure

Here is a screen grab of the running code:
Vram

Edit: I’ll add a full example in my Xojo Declares Book in the future.

wmic can do that too.

wmic path Win32_videocontroller get AdapterRAM

Thanks for replying and for the example, Eugene.
Unfortunately, I don’t see VRAM value in your listing, or am I wrong?

Thanks for your reply, Christian.

I avoid looking for this kind of information in the Registry as much as possible, so I will favor Matthew’s solution.

Jean-Luc

Thanks a lot, Matthew, works like a charm and matches my need.

I think I should have a look (and a little bit more) at WMIC… :grin:

Jean-Luc

Oups…
After coding and testing on my PC and comparing with the Graphic Card properties (as displayed in Advanced Display Parameters / Screen 1 video card properties), I get different results:

→ wmic returns 1 073 741 824 bytes, that is 1 GB
→ Video Card properties displays:
Total available VRAM 4181 MB
Dedicated VRAM 128 MB
System VRAM 0 MB
Shared System RAM 4053 MB

Where is the problem?

Jean-Luc

Using Christian’s Registry solution, I find (in HardwareInformation.MemorySize) a value of 00 00 00 40, that is &h400000000 or 1 GB.
So wmic returns the same value.

Why does Video Card properties display other information? I’m quiet sure my old PC does not have 4 GB VRAM.
Any idea?

Jean-Luc

Hello @Jean-Luc_ARNAUD,

My apologies. I thought VRAM means virtual random access memory. It appears it means video random access memory.

Warm regards.

To be clear, the registry entry is populated every time the system boots up, but wmic calculates it in real time.

To answer your question about the VRAM being 4GB in total, it’s because on many SoC’s like in laptops, the graphics card shares some or all of the memory with the rest of the system. So you have 4 GB of memory for everything. From a graphics perspective it’s much slower than dedicated GDDR memory chips but it gives you more capacity.

The Video Card Properties panel is telling you how much total memory your gpu can access once it goes beyond its dedicated memory.

Edit: After a bit of experimentation, it seems the wmic AdapterRAM property is capped at 4gb because it is using a 32 bit unsigned integer. Because of this, on systems with more than 4gb of available vram (like on my system with 24 gb), the value returned by wmic grossly undercounts what is available.

The registry approach returns a hexadecimal quad word that you can use to get the actual total value of available memory to your gpu.

1 Like

Very clear, Christian. Thanks a lot.
So, I will code information on VRAM on the Graphic Card AND total available VRAM, including what is shared by the system.

Thanks to all for your replies.

Jean-Luc

Note: Microsoft should now rewrite Windows only on 64Bit…

No problem, Eugene, errare humanum est.
It’s better to reply, and eventually to correct a mistake after, instead of not sharing knowledge.
Your code will probably be of a great help for somebody, and I will keep it for a future need.

Jean-Luc