Displaying Solaris kernel memory usage


The mdb utility that ships with Solaris 10 is amazing, and allows you to view a wide array of kernel data. Mdb ships with numerous commands (also referred to as dcmds) to view information, and one of my personal favorites is ‘::memstat’:

$ mdb -k

> ::memstat
Page Summary Pages MB %Tot
------------ ---------------- ---------------- ----
Kernel 13834 108 11%
Anon 15663 122 12%
Exec and libs 2040 15 2%
Page cache 7827 61 6%
Free (cachelist) 14248 111 11%
Free (freelist) 75882 592 59%

Total 129494 1011
Physical 127634 997

As you can probably tell by it’s name, memstat displays how a system is using memory, and is typically the first place I look to see how memory is allocated. To see how the kernel is using the memory listed in the ‘::memstat’ output, you can use the ‘::kmastat’ dcmd:

$ mdb -k

> **::kmastat**

cache buf buf buf memory alloc alloc
name size in use total in use succeed fail
------------------------- ------ ------ ------ --------- --------- -----
kmem_magazine_1 16 3371 3556 57344 3371 0
kmem_magazine_3 32 16055 16256 524288 16055 0
kmem_magazine_7 64 29166 29210 1884160 29166 0
kmem_magazine_15 128 6711 6741 876544 6711 0
kmem_magazine_31 256 0 0 0 0 0
kmem_magazine_47 384 0 0 0 0 0
kmem_magazine_63 512 0 0 0 0 0
kmem_magazine_95 768 0 0 0 0 0
kmem_magazine_143 1152 0 0 0 0 0
kmem_slab_cache 56 7204 7250 409600 7204 0
kmem_bufctl_cache 24 33904 34239 827392 33904 0
kmem_bufctl_audit_cache 128 0 0 0 0 0

If you are trying to figure out how mdb works, check out the sample mdb chapter from the next revision of Solaris kernel internals.

This article was posted by Matty on 2006-06-17 21:48:00 -0400 -0400