Cim_PhysicalMemory and Win32_ComputerSystem return different amount of memory

送分小仙女□ 提交于 2019-12-10 15:16:33

问题


I'm trying to write a PowerShell script that shows the amount of memory installed in a server (a physical server with 512 GB).
I've tried three different methods and I get different results.

  1. Win32_PhysicalMemory

    (Get-WmiObject Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Sum)/1GB
    

    This returns 255.99 GB.

  2. Win32_ComputerSystem

    $InstalledRAM = Get-WmiObject -Class Win32_ComputerSystem
    [Math]::Round(($InstalledRAM.TotalPhysicalMemory/1GB), 2)
    

    This returns 511.88 GB.

  3. Cim_PhysicalMemory

    $MaxRam = 0
    $RamPool = (Get-CimInstance -Class "Cim_PhysicalMemory" | % {$_.Capacity})
    
    foreach ($RamBank in $RamPool) {
        $MaxRam += $RamBank/1024/1024
    }
    

    This returns 255.99 GB.

Taskmanager/systeminfo show there is 512 GB installed.

When I use Win32_PhysicalMemory to print out the memory installed in the different memory banks, I get 8 banks of 32 GB. But I'm sure the server contains 512 GB.

Can someone explain to me why method 1 and 3 only return 256 GB?

Update:
When I look in the bios I see that there is 256 GB assigned to each physical processor. My knowledge is not so advanced but is it possible that I have to request the NUMA-nodes first and foreach node retrieve the amount of memory assigned to it? Or is this not possible with Powershell?


回答1:


CIM_PhysicalMemory and Win32_PhysicalMemory are the same [1].

This property is inherited from CIM_PhysicalMemory.

This is where the value is obtained from[1].

This value comes from the Memory Device structure in the SMBIOS version information. For SMBIOS versions 2.1 thru 2.6 the value comes from the Size member. For SMBIOS version 2.7+ the value comes from the Extended Size member.

The SMBIOS standard says [2]

The Extended Size field is intended to represent memory devices larger than 32,767 MB (32 GB - 1 MB), which cannot be described using the Size field. This field is only meaningful if the value in the Size field is 7FFFh. For compatibility with older SMBIOS parsers, memory devices smaller than (32 GB - 1 MB) should be represented using their size in the Size field, leaving the Extended Size field set to 0.

As you say, you have 8x64GB, but displayed 8x32GB, it doesn't like like a NUMA issue to me. If it's NUMA, I'd expect you get 4x32GB displayed. Also, I have a server with 8x32GB and 2 sockets. Hence, if it's a NUMA issue, I'd expect to see the same issue on my box. However, I get the amount displayed correctly. It looks like your BIOS uses SMBIOS standad strcuture before 2.7.1, which is strange though, as it's from 2011.

Please try to verify your SMBIOS version with

(Get-CimInstance -ClassName Win32_BIOS) | Select-Object SMBIOS*

For me, SMBIOSVersion returns the vendor's BIOS version number instead of the standard, but SMBIOSMajorVersionand SMBIOSMinorVersion are returning the proper value.

Win32_ComputerSystem queries the information from the Win32 api [3].

Total size of physical memory. Be aware that, under some circumstances, this property may not return an accurate value for the physical memory. For example, it is not accurate if the BIOS is using some of the physical memory. For an accurate value, use the Capacity property in Win32_PhysicalMemory instead.



来源:https://stackoverflow.com/questions/45837347/cim-physicalmemory-and-win32-computersystem-return-different-amount-of-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!