How can a computer/OS tell what kind of RAM is in the machine?

Solution 1:

RAM sticks have a small chip on them called the Serial Presence Detect, which contains information such as capacity, preferred timings, manufacturer, and even a serial number.

SPD information is accessible by OSes using the i2c bus (which also includes things like temperature sensors). I think you can directly read the SPDs from Linux using various i2c utilities.

This image from the Wikipedia article has a good picture of it: e

UPDATE:

Some PCs have soldered on RAM instead of RAM DIMMs/SODIMMs. The firmware on these PCs come from the factory with the information about the RAM built in to the same flash storage that the firmware lives on - and then the firmware will setup a "virtual SPD" that OSes can use to query/detect in the same manner.

From gregdavill.github.io:

When laptops started moving memory onto the mainboard, instead of in sockets, they still needed a mechanism to emulate SPD info, so that your OS can correctly detect and show you information about the memory installed in your system. Instead of populating an EEPROM, they simply embed this info inside the BIOS FLASH. Part of the BIOS boot sequence is to extract an SPD table from FLASH, and create a virtual SPD that the OS can query.

That article specifically talks about a Dell XPS13 - and also mentions "resistor straps" - the firmware will check (via GPIO pins accessible via the chipset) for the presence of these straps--allowing the same firmware for different motherboard versions. From there the firmware sets the virtual SPD accordingly.

Solution 2:

On Windows:

wmic memoryChip get /?

Will give you various RAM information you can ask for right from the command prompt.

For example,

wmic memorychip get serialnumber

Gives you the serial number. You can also use Speed, Model sometimes, Manufacturer and more.

WMI is the Windows method of querying SMBIOS data. Apple, Linux, Windows and anyone else who wants to run on most hardware made needs to support SMBIOS at some level, for different reasons.

You can use SMBIOS (e.g. through WMI or WMIC in Windows) to also gather hard drive information, network information (is it a 10/100 or 10/100/1000 card?).

To take it one step further, every manufacturer has a code for MAC addresses on NICs. RAM also has a manufacturers code. So all you have to do to get their code, for example my 2 x2GB in this laptop are 830B, is build a database for the manufacturers (830B might be one brand and then resold too!) and also what models mean what. That is how CPUz works I believe—basic queries and a really complete and current database.

Solution 3:

The memory speed and type is negotiated with the bios and can be read by the operating system.

There is a very good website giving you a deeper level of understanding about these things at http://www.computermemoryupgrade.net/index1.html

But you can easily figure out which types and speed you have without opening the cover via:

Apple -> About This Mac -> More Info -> System Report

Open Hardware -> Memory

You should see each stick of RAM including Size, Type and Speed (and for fun, Status to make sure it's ok)

System Report with Memory

Solution 4:

On many Linux distributions (e.g. Debian), you can use the lshw hardware lister

sudo lshw |grep DDR
         description: SODIMM DDR3 Synchronous 1067 MHz (0.9 ns)
         description: SODIMM DDR3 Synchronous 1067 MHz (0.9 ns)

I guess that RAM, like all other hardware, reports its description and capabilities to the OS. If Linux can do it, I see no reason why OSX can't.

If your distribution doesn't have lshw installed, you can install it using your package manager, e.g.

aptitude install lshw

or download it from the project website.

Solution 5:

On Mac OS X run from terminal:

$ system_profiler SPMemoryDataType