The simplest way to check total installed RAM is using the sysctl
command:
sysctl hw.physmem
sysctl hw.realmem
This will display physical memory in bytes. For human-readable output:
sysctl -h hw.physmem
The top
utility provides real-time memory statistics:
top
Look for these key memory metrics in the header:
Mem: 1234M Active, 567M Inact, 890M Wired, 12M Cache
Swap: 1024M Total, 512M Used
For detailed hardware information including RAM slots and configuration:
dmidecode -t memory
Sample output showing DIMM details:
Handle 0x1000, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Maximum Capacity: 32 GB
Number Of Devices: 4
Handle 0x1100, DMI type 17, 34 bytes
Memory Device
Array Handle: 0x1000
Size: 8192 MB
Form Factor: DIMM
Type: DDR4
Speed: 2666 MHz
For virtualized environments or when dmidecode isn't available:
# Kernel memory map
vmstat -h
# Show memory hardware (requires root)
pciconf -lv | grep -i memory
# FreeBSD-specific memory reporting
grep memory /var/run/dmesg.boot
For automation purposes, extract just the numeric value in megabytes:
sysctl -n hw.physmem | awk '{print $1/1024/1024}'
Or for a complete JSON output suitable for monitoring systems:
{
"total_memory_mb": $(sysctl -n hw.physmem | awk '{print $1/1024/1024}'),
"free_memory_mb": $(sysctl -n vm.stats.vm.v_free_count | awk '{print $1*4}')
}
The simplest way to check RAM on FreeBSD is using the sysctl
command:
sysctl hw.physmem
This will output the total physical memory in bytes. For human-readable format:
sysctl -h hw.physmem
For more detailed memory information including slot configuration (requires root privileges):
dmidecode -t memory
Sample output showing DIMM slots and sizes:
Handle 0x1000, DMI type 16, 15 bytes
Physical Memory Array
Maximum Capacity: 64 GB
Number Of Devices: 4
Handle 0x1100, DMI type 17, 21 bytes
Memory Device
Size: 16 GB
Form Factor: DIMM
Locator: DIMM0
The top
utility shows real-time memory usage including total RAM:
top
Look for the "Mem" line in the header:
Mem: 1481M Active, 647M Inact, 274M Wired, 128M Cache, 247M Buf, 684M Free
For scripting purposes, combine commands with grep:
sysctl -n hw.physmem | awk '{print $1/1024/1024 " MB"}'
Or for just the numeric value in MB:
sysctl -n hw.realmem | awk '{print int($1/1024/1024)}'
For server administrators needing DIMM details:
pciconf -lv | grep -A4 memory
This shows memory controller information and can help identify ECC/non-ECC configurations.