3 leak, kmem, umem \- help find memory leaks
35 examines the named processes, which
36 should be sharing their data and bss segments,
38 It uses a mark and sweep-style algorithm to
39 determine which allocated blocks are no longer
40 reachable from the set of root pointers.
41 The set of root pointers is created by looking through
42 the shared bss segment as well as each process's registers.
44 Unless directed otherwise,
46 prints, for each block, a line with seven space-separated fields:
49 the address of the block,
50 the size of the block,
51 the first two words of the block,
52 and the function names represented by the first two words of the block.
53 Usually, the first two words of the block
54 contain the malloc and realloc tags
57 useful for finding who allocated the leaked blocks.
65 will instead present a sequence of
67 commands that show each leaky allocation site.
70 a comment appears next to each command to
71 indicate how many lost blocks were allocated
72 at that point in the program.
75 the comments are extended to indicate also the total
76 number of bytes lost at that point in the program,
77 and an additional comment line gives the
78 overall total number of bytes.
84 will print information as decribed above,
85 but for all allocated blocks,
91 will print information as decribed above,
92 but for all free blocks,
94 or those that are not yet
95 in use (fragmentation?).
100 options can be combined.
106 will print a Plan 9 image file
107 graphically summarizing the memory arenas.
108 In the image, each pixel represents
113 .TP "\w'\fIbright blue\fR 'u
115 Completely allocated.
118 Contains malloc headers.
121 Contains malloc headers for leaked memory.
124 Contains leaked memory.
130 Padding to fill out the image.
132 The bright pixels representing headers help in
133 counting the number of blocks.
134 Magnifying the images with
138 If given a name rather than a list of process ids,
140 echoes back a command-line with process ids of every process
145 option specifies a binary to go on the
147 command-line used to inspect the
148 processes, and is only necessary
149 when inspecting processes started
150 from stripped binaries.
153 prints a summary of all allocated blocks in the process with id
155 Each line of the summary gives the count and total size of
156 blocks allocated at an allocation point.
157 The list is sorted by count in decreasing order.
159 prints summarizes all allocations, not just
160 memory leaks, but it is faster and requires less memory than
166 but prints a summary for the running kernel.
170 This depends on the fact that there is only
173 running; if there were more, the output of
175 would need editing before sending to the shell.
181 src(0x0000bf1b); // 64
182 src(0x000016f5); // 7
183 src(0x0000a988); // 7
187 View the memory usage graphic for the window system.
190 % leak -b rio | rc | page
193 List the top allocation points in the kernel,
194 first by count and then by total size:
198 % kmem | sort -nr +1 | sed 10q
201 .B /sys/lib/acid/leak
203 .B /sys/src/cmd/aux/acidleak.c
219 depend on the internal structure of the
220 libc pool memory allocator (see
222 Since the ANSI/POSIX environment uses a different
225 will not work on APE programs.
230 can consume more memory than the process(es) being examined.
232 These commands require
233 .B /sys/src/libc/port/pool.acid
234 to be present and generated from