kmem(1): new program [rsc] --rwxrwxr-x M 303009 rsc sys 468 Mar 9 16:36 rc/bin/kmem [rsc] --rw-rw-r-- M 303009 glenda sys 3022 Mar 9 16:36 sys/lib/acid/leak [diffs elided - too long] [diff -c /n/sourcesdump/2006/0309/plan9/sys/lib/acid/leak /n/sourcesdump/2006/0310/plan9/sys/lib/acid/leak] [rsc] --rw-rw-r-- M 303009 glenda sys 3307 Mar 9 16:36 sys/man/1/leak /n/sourcesdump/2006/0309/plan9/sys/man/1/leak:19,24 - /n/sourcesdump/2006/0310/plan9/sys/man/1/leak:19,29 .I width ] .I pid ... + .PP + .B kmem + [ + .I kernel + ] .SH DESCRIPTION .I Leak examines the named processes, which /n/sourcesdump/2006/0309/plan9/sys/man/1/leak:57,63 - /n/sourcesdump/2006/0310/plan9/sys/man/1/leak:62,70 .PP If the .B -b - option is given, leak will print a Plan 9 image file + option is given, + .I leak + will print a Plan 9 image file graphically summarizing the memory arenas. In the image, each pixel represents .I res /n/sourcesdump/2006/0309/plan9/sys/man/1/leak:102,107 - /n/sourcesdump/2006/0310/plan9/sys/man/1/leak:109,120 processes, and is only necessary when inspecting processes started from stripped binaries. + .PP + .I Kmem + prints a summary of all allocated blocks in the running kernel. + Each line of the summary gives + the count and total size of blocks allocated at an allocation point. + The list is sorted by count in decreasing order. .SH EXAMPLES List lost blocks in .IR 8.out . /n/sourcesdump/2006/0309/plan9/sys/man/1/leak:113,132 - /n/sourcesdump/2006/0310/plan9/sys/man/1/leak:126,153 would need editing before sending to the shell. .IP .EX - g% leak -s 8.out + % leak -s 8.out leak -s 229 230 - g% leak -s 8.out | rc + % leak -s 8.out | rc src(0x0000bf1b); // 64 src(0x000016f5); // 7 src(0x0000a988); // 7 - g% + % .EE .LP View the memory usage graphic for the window system. .IP .EX - g% leak -b rio | rc | page + % leak -b rio | rc | page .EE + .PP + List the top allocation points in the kernel, + first by count and then by total size: + .IP + .EX + % kmem | sed 10q + % kmem | sort -nr +1 | sed 10q + .EE .SH SOURCE .B /sys/lib/acid/leak .br /n/sourcesdump/2006/0309/plan9/sys/man/1/leak:133,141 - /n/sourcesdump/2006/0310/plan9/sys/man/1/leak:154,169 .B /sys/src/cmd/aux/acidleak.c .br .B /rc/bin/leak + .br + .B /rc/bin/kmem .SH BUGS - Leak depends on the internal structure of the + .I Leak + and + .I kmem + depend on the internal structure of the libc pool memory allocator (see .IR pool (2)). Since the ANSI/POSIX environment uses a different - allocator, leak will not work on APE programs. + allocator, + .I leak + will not work on APE programs.