Lines Matching +full:in +full:- +full:memory

1 Kernel Memory Leak Detector
4 Kmemleak provides a way of detecting possible kernel memory leaks in a
9 Valgrind tool (``memcheck --leak-check``) to detect the memory leaks in
10 user-space applications.
13 -----
15 CONFIG_DEBUG_KMEMLEAK in "Kernel hacking" has to be enabled. A kernel
16 thread scans the memory every 10 minutes (by default) and prints the
20 # mount -t debugfs nodev /sys/kernel/debug/
22 To display the details of all the possible scanned memory leaks::
26 To trigger an intermediate memory scan::
30 To clear the list of all current possible memory leaks::
37 Note that the orphan objects are listed in the order they were allocated
41 Memory scanning parameters can be modified at run-time by writing to the
44 - off
46 - stack=on
48 - stack=off
50 - scan=on
51 start the automatic memory scanning thread (default)
52 - scan=off
53 stop the automatic memory scanning thread
54 - scan=<secs>
55 set the automatic memory scanning period in seconds
57 - scan
58 trigger a memory scan
59 - clear
60 clear list of current memory leak suspects, done by
63 - dump=<addr>
66 Kmemleak can also be disabled at boot-time by passing ``kmemleak=off`` on
69 Memory may be allocated or freed before kmemleak is initialised and
70 these actions are stored in an early log buffer. The size of this buffer
81 ---------------
83 The memory allocations via :c:func:`kmalloc`, :c:func:`vmalloc`,
86 information like size and stack trace, are stored in a rbtree.
90 An allocated block of memory is considered orphan if no pointer to its
92 scanning the memory (including saved registers). This means that there
95 memory leak.
101 2. scan the memory starting with the data section and stacks, checking
102 the values against the addresses stored in the rbtree. If
111 Some allocated memory blocks have pointers stored in the kernel's
118 ---------------------------------------
139 ---------------------------------
141 To allow access to previously found memory leaks after kmemleak has been
144 a large part of physical memory.
146 In this situation, you may reclaim memory with::
151 ------------
155 - ``kmemleak_init`` - initialize kmemleak
156 - ``kmemleak_alloc`` - notify of a memory block allocation
157 - ``kmemleak_alloc_percpu`` - notify of a percpu memory block allocation
158 - ``kmemleak_vmalloc`` - notify of a vmalloc() memory allocation
159 - ``kmemleak_free`` - notify of a memory block freeing
160 - ``kmemleak_free_part`` - notify of a partial memory block freeing
161 - ``kmemleak_free_percpu`` - notify of a percpu memory block freeing
162 - ``kmemleak_update_trace`` - update object allocation stack trace
163 - ``kmemleak_not_leak`` - mark an object as not a leak
164 - ``kmemleak_ignore`` - do not scan or report an object as leak
165 - ``kmemleak_scan_area`` - add scan areas inside a memory block
166 - ``kmemleak_no_scan`` - do not scan a memory block
167 - ``kmemleak_erase`` - erase an old value in a pointer variable
168 - ``kmemleak_alloc_recursive`` - as kmemleak_alloc but checks the recursiveness
169 - ``kmemleak_free_recursive`` - as kmemleak_free but checks the recursiveness
175 - ``kmemleak_alloc_phys``
176 - ``kmemleak_free_part_phys``
177 - ``kmemleak_not_leak_phys``
178 - ``kmemleak_ignore_phys``
181 --------------------------------------
183 The false negatives are real memory leaks (orphan objects) but not
184 reported by kmemleak because values found during the memory scanning
190 The false positives are objects wrongly reported as being memory leaks
193 the memory block is known not to contain other pointers and it will no
197 systems, because of pointers temporarily stored in CPU registers or
199 the minimum age of an object to be reported as a memory leak.
202 -------------------------
204 The main drawback is the reduced performance of memory allocation and
205 freeing. To avoid other penalties, the memory scanning is only performed
212 number of false negatives. However, it is likely that a real memory leak
215 Another source of false negatives is the data stored in non-pointer
216 values. In a future version, kmemleak could only scan the pointer
217 members in the allocated structures. This feature would solve many of
221 block doesn't need to be freed (some cases in the init_call functions),
223 macro or the pointer is stored in a location not scanned by kmemleak.
227 Testing with kmemleak-test
228 --------------------------
230 To check if you have all set up to use kmemleak, you can use the kmemleak-test
231 module, a module that deliberately leaks memory. Set CONFIG_DEBUG_KMEMLEAK_TEST
232 as module (it can't be used as built-in) and boot the kernel with kmemleak
235 # modprobe kmemleak-test
240 memory leaks``. Then read the file to see then::