|
@@ -27,6 +27,13 @@ To trigger an intermediate memory scan:
|
|
|
|
|
|
# echo scan > /sys/kernel/debug/kmemleak
|
|
# echo scan > /sys/kernel/debug/kmemleak
|
|
|
|
|
|
|
|
+To clear the list of all current possible memory leaks:
|
|
|
|
+
|
|
|
|
+ # echo clear > /sys/kernel/debug/kmemleak
|
|
|
|
+
|
|
|
|
+New leaks will then come up upon reading /sys/kernel/debug/kmemleak
|
|
|
|
+again.
|
|
|
|
+
|
|
Note that the orphan objects are listed in the order they were allocated
|
|
Note that the orphan objects are listed in the order they were allocated
|
|
and one object at the beginning of the list may cause other subsequent
|
|
and one object at the beginning of the list may cause other subsequent
|
|
objects to be reported as orphan.
|
|
objects to be reported as orphan.
|
|
@@ -42,6 +49,8 @@ Memory scanning parameters can be modified at run-time by writing to the
|
|
scan=<secs> - set the automatic memory scanning period in seconds
|
|
scan=<secs> - set the automatic memory scanning period in seconds
|
|
(default 600, 0 to stop the automatic scanning)
|
|
(default 600, 0 to stop the automatic scanning)
|
|
scan - trigger a memory scan
|
|
scan - trigger a memory scan
|
|
|
|
+ clear - clear list of current memory leak suspects, done by
|
|
|
|
+ marking all current reported unreferenced objects grey
|
|
dump=<addr> - dump information about the object found at <addr>
|
|
dump=<addr> - dump information about the object found at <addr>
|
|
|
|
|
|
Kmemleak can also be disabled at boot-time by passing "kmemleak=off" on
|
|
Kmemleak can also be disabled at boot-time by passing "kmemleak=off" on
|
|
@@ -87,6 +96,27 @@ avoid this, kmemleak can also store the number of values pointing to an
|
|
address inside the block address range that need to be found so that the
|
|
address inside the block address range that need to be found so that the
|
|
block is not considered a leak. One example is __vmalloc().
|
|
block is not considered a leak. One example is __vmalloc().
|
|
|
|
|
|
|
|
+Testing specific sections with kmemleak
|
|
|
|
+---------------------------------------
|
|
|
|
+
|
|
|
|
+Upon initial bootup your /sys/kernel/debug/kmemleak output page may be
|
|
|
|
+quite extensive. This can also be the case if you have very buggy code
|
|
|
|
+when doing development. To work around these situations you can use the
|
|
|
|
+'clear' command to clear all reported unreferenced objects from the
|
|
|
|
+/sys/kernel/debug/kmemleak output. By issuing a 'scan' after a 'clear'
|
|
|
|
+you can find new unreferenced objects; this should help with testing
|
|
|
|
+specific sections of code.
|
|
|
|
+
|
|
|
|
+To test a critical section on demand with a clean kmemleak do:
|
|
|
|
+
|
|
|
|
+ # echo clear > /sys/kernel/debug/kmemleak
|
|
|
|
+ ... test your kernel or modules ...
|
|
|
|
+ # echo scan > /sys/kernel/debug/kmemleak
|
|
|
|
+
|
|
|
|
+Then as usual to get your report with:
|
|
|
|
+
|
|
|
|
+ # cat /sys/kernel/debug/kmemleak
|
|
|
|
+
|
|
Kmemleak API
|
|
Kmemleak API
|
|
------------
|
|
------------
|
|
|
|
|