Reputation: 1084
How can I detect the current RAM config? I need to ask windows about if the RAM is currently running in single, dual or quad channel.
I have searched a lot, and not found any similar questions on this or other sites, which is quite surprising to me.
I'm working with C++
, but this question really applies to all programming languages the same way since it's about what windows function or powershell
/cmd
command will give me the info I need.
Upvotes: 18
Views: 7003
Reputation: 7697
Look at the SMBIOS specifications: System Management BIOS (SMBIOS) Reference Specification. Actually, latest version is dated 14 May 2018.
Step 1:
You need to read the Current Interleave
from
7.6 Memory Controller Information (Type 5)
for older versions, and then follow the notes about how to read the newest structures.
Step 2: You need to get the memory devices from:
7.38 Memory Channel (Type 37)
Offset Name Length Value Description 06h Memory Device Count(n) BYTE Varies Number of Memory Devices (Type 11h) that are associated with this channel This value also defines the number of Load/Handle pairs that follow.
You should read that Count(n)
memory devices with their associated channels.
Step 3: all together, You will end up with a table as follows:
Channel 1: DIMM #0
Channel 1: DIMM #1
Channel 2: DIMM #0
Channel 2: DIMM #1
Luckily, in the SMBIOS specifications there are some examples.
For instance look at section 7.7.3 Memory subsystem
:
04h ; 2-way interleave currently used
As the specifications are frequently subject to change and some are obsolete, I wouldn't rely on any out-of-the-box Windows WMI/API. The best way I can suggest You, is to read the RAW SMBIOS DATA in one shot and build a simple table like the one above. Here is how: SMBIOS Demystified
Moreover, I believe You can't do any further assumption about the real effective channel speed. You may need to gather some othe information about the speed of each DIMM module.
IMHO, posting the source code for such a task goes far beyond the current question scope, so there are some links: the best reference about that topic is dmidecode but, as I feel good with Delphi, I would prefer to look at this Delphi/FPC post: Reading the SMBios Tables using Delphi.
Upvotes: 2
Reputation: 418
InterleavePosition
is what you're looking for though. One came up as 2,2,2
because it's running 3 sticks in dual channel. What you need to find out is how to identify a machine running single-channel so that you can use the output of this command:
wmic memorychip get InterleavePosition
Edit: Actually not sure about the dual channel with 3 sticks. Some research suggests most motherboard nowadays will make the odd one out single channel.
So from the MSDN, this is what we have to work with in terms of digging up system info about interleaved memory.
Position of the physical memory in an interleave. For example, in a 2:1 interleave, a value of "1" indicates that the memory is in the "even" position.
This property is inherited from CIM_PhysicalMemory.
0 - Noninterleaved
1 - First position
2 - Second position
Plus InterleaveDataDepth
which says this:
InterleaveDataDepth
Unsigned 16-bit integer maximum number of consecutive rows of data that are accessed in a single interleaved transfer from the memory device. If the value is 0 (zero), the memory is not interleaved.
Mind you, interleave is a fancy word for "share mutually" which is similar to multi-channel nowadays but it's not the same thing. From wiki on interleaved memory:
It is different from multi-channel memory architectures, primarily as interleaved memory is not adding more channels between the main memory and the memory controller. However, channel interleaving is also possible...[]
Using this, I'll share what it looks like to have 4 RAM sticks in dual channel using cmd.exe:
Edit: Several people have confirmed these values work just fine on some machines but too often return puzzling/nonsense values.
Upvotes: 6