6.4. Physical Memory AllocationYou can use the standard Solaris tools to observe the total physical memory configured, memory used by the kernel, and the amount of "free" memory in the system. 6.4.1. Total Physical MemoryFrom the output of the Solaris prtconf command, you can ascertain the amount of total physical memory. # prtconf System Configuration: Sun Microsystems i86pc Memory size: 2048 Megabytes System Peripherals (Software Nodes): 6.4.2. Free MemoryUse the vmstat command to measure free memory. The first line of output from vmstat is an average since boot, so the real free memory figure is available on the second line. The output is in kilobytes. In this example, observe the value of approximately 970 Mbytes of free memory. # vmstat 3 kthr memory page disk faults cpu r b w swap free re mf pi po fr de sr cd cd f0 s0 in sy cs us sy id 0 0 0 1512468 837776 160 20 12 12 12 0 0 0 1 0 0 589 3978 150 2 0 97 54 0 0 1720376 995556 1 13 27 0 0 0 0 20 176 0 0 1144 4948 1580 1 2 97 0 0 0 1720376 995552 6 65 21 0 0 0 0 22 160 0 0 1191 7099 2139 2 3 95 0 0 0 1720376 995536 0 0 13 0 0 0 0 21 190 0 0 1218 6183 1869 1 3 96 The free memory reported by Solaris includes the cache list portion of the page cache, meaning that you can expect to see a larger free memory size when significant file caching is occurring. In Solaris 8, free memory did not include pages that were available for use from the page cache, which had recently been added. After a system was booted, the page cache gradually grew and the reported free memory dropped, usually hovering around 8 megabytes. This led to some confusion because Solaris 8 reported low memory even though plenty of pages were available for reuse from the cache. Since Solaris 9, the free column of vmstat has included the cache list portion and as such is a much more useful measure of free memory. 6.4.3. Using the memstat Command in MDBYou can use an mdb command to view the allocation of the physical memory into the buckets described in previous sections. The macro is included with Solaris 9 and later. sol9# mdb -k Loading modules: [ unix krtld genunix ip ufs_log logindmux ptm cpc sppp ipc random nfs ] > ::memstat Page Summary Pages MB %Tot ------------ ---------------- ---------------- ---- Kernel 53444 208 10% Anon 119088 465 23% Exec and libs 2299 8 0% Page cache 29185 114 6% Free (cachelist) 347 1 0% Free (freelist) 317909 1241 61% Total 522272 2040 Physical 512136 2000 The categories are described as follows:
If you want this functionality for Solaris 8, copy the downloadable memory.so library into /usr/lib/mdb/kvm/sparcv9 and then use ::load memory before running ::memstat. (Note that this is not Sun-supported code, but it is considered low risk since it affects only the mdb user-level program.) # wget http://www.solarisinternals.com/si/downloads/memory.so # cp memory.so /usr/lib/mdb/kvm/sparcv9 # mdb -k Loading modules: [ unix krtld genunix ip ufs_log logindmux ptm cpc sppp ipc random nfs ] > ::load memory > ::memstat |