Memory Utilization on FreeBSD

Recently, I was troubleshooting an issue with the memory my computer was seeing. I have 4GB installed on my computer and am running a 32bit operating system. This doesn't mean I can't use more than 3GB of memory, it just makes it a bit more interesting. In 32bit systems, a single process can only access up to 4GB of memory. In practice, that is something less. How much less depends on how you have your BIOS configured. In many BIOS's, there's a feature called Memory Remap and depending on whether it is enabled or not will change how much memory your system can access.

I found this nifty program to show me easily how much memory my PC has. Now, I realize I don't need this as this information is available in top, dmesg, and sysctl but this puts it all together in one spot. Download perl script which is written by Ralf S. Engelschall:

# fetch http://www.cyberciti.biz/files/scripts/freebsd-memory.pl.txt
# mv freebsd-memory.pl.txt /usr/local/bin/free
# chmod +x /usr/local/bin/free

Make sure perl is installed. Now to display or list total system memory usage type

$ free

Output:

tethys:/home/rnejdl>free             
SYSTEM MEMORY INFORMATION:
mem_wire:         773242880 (    737MB) [ 25%] Wired: disabled for paging out
mem_active:  +   1284390912 (   1224MB) [ 41%] Active: recently referenced
mem_inactive:+    424820736 (    405MB) [ 13%] Inactive: recently not referenced
mem_cache:   +     69627904 (     66MB) [  2%] Cached: almost avail. for allocation
mem_free:    +    518475776 (    494MB) [ 16%] Free: fully available for allocation
mem_gap_vm:  +      1552384 (      1MB) [  0%] Memory gap: UNKNOWN
-------------- ------------ ----------- ------
mem_all:     =   3072110592 (   2929MB) [100%] Total real memory managed
mem_gap_sys: +     55828480 (     53MB)        Memory gap: Kernel?!
-------------- ------------ -----------
mem_phys:    =   3127939072 (   2983MB)        Total real memory available
mem_gap_hw:  +     93286400 (     88MB)        Memory gap: Segment Mappings?!
-------------- ------------ -----------
mem_hw:      =   3221225472 (   3072MB)        Total real memory installed

SYSTEM MEMORY SUMMARY:
mem_used:        2208301056 (   2106MB) [ 68%] Logically used memory
mem_avail:   +   1012924416 (    966MB) [ 31%] Logically available memory
-------------- ------------ ----------- ------
mem_total:   =   3221225472 (   3072MB) [100%] Logically total memory

This shows that my system is recognizing 3GB of memory. The most I believe I can get a system to see is about 3.5GB. Interestingly enough, enabling memory remap actually reduced this to 2GB which won't work for me.

As with many FreeBSD users, I am waiting for a 64bit Nvidia driver so I can run more than 4GB of memory safely. At present, I have to add machdep.disable_mtrrs=1 to my /boot/loader.conf in order to be able to use this much memory with 32Bit FreeBSD and the NVIDIA driver.

I have since upgraded to 64bit FreeBSD with 12GB of memory as seen below:

[tethys]:/home/rnejdl> free
SYSTEM MEMORY INFORMATION:
mem_wire:        1597874176 (   1523MB) [ 12%] Wired: disabled for paging out
mem_active:  +   2621136896 (   2499MB) [ 21%] Active: recently referenced
mem_inactive:+   7561408512 (   7211MB) [ 60%] Inactive: recently not referenced
mem_cache:   +    255447040 (    243MB) [  2%] Cached: almost avail. for allocation
mem_free:    +    400023552 (    381MB) [  3%] Free: fully available for allocation
mem_gap_vm:  +       643072 (      0MB) [  0%] Memory gap: UNKNOWN
-------------- ------------ ----------- ------
mem_all:     =  12436533248 (  11860MB) [100%] Total real memory managed
mem_gap_sys: +    410058752 (    391MB)        Memory gap: Kernel?!
-------------- ------------ -----------
mem_phys:    =  12846592000 (  12251MB)        Total real memory available
mem_gap_hw:  +     38309888 (     36MB)        Memory gap: Segment Mappings?!
-------------- ------------ -----------
mem_hw:      =  12884901888 (  12288MB)        Total real memory installed

SYSTEM MEMORY SUMMARY:
mem_used:        4668022784 (   4451MB) [ 36%] Logically used memory
mem_avail:   +   8216879104 (   7836MB) [ 63%] Logically available memory
-------------- ------------ ----------- ------
mem_total:   =  12884901888 (  12288MB) [100%] Logically total memory