Trace outstanding memory allocations that weren't freed.
Trace outstanding memory allocations that weren't freed.
Supports both user-mode allocations made with malloc/free and kernel-mode
Supports both user-mode allocations made with malloc/free and kernel-mode
allocations made with kmalloc/kfree.
allocations made with kmalloc/kfree.
interval interval in seconds to print outstanding allocations
count number of times to print the report before exiting
optional arguments:
optional arguments:
-h, --help show this help message and exit
-h, --help show this help message and exit
-p PID, --pid PID the PID to trace; if not specified, trace kernel
-p PID, --pid PID the PID to trace; if not specified, trace kernel
allocs
allocs
-t, --trace print trace messages for each alloc/free call
-t, --trace print trace messages for each alloc/free call
-i INTERVAL, --interval INTERVAL
interval in seconds to print outstanding allocations
-a, --show-allocs show allocation addresses and sizes as well as call
-a, --show-allocs show allocation addresses and sizes as well as call
stacks
stacks
-o OLDER, --older OLDER
-o OLDER, --older OLDER
...
@@ -139,6 +175,13 @@ optional arguments:
...
@@ -139,6 +175,13 @@ optional arguments:
execute and trace the specified command
execute and trace the specified command
-s SAMPLE_RATE, --sample-rate SAMPLE_RATE
-s SAMPLE_RATE, --sample-rate SAMPLE_RATE
sample every N-th allocation to decrease the overhead
sample every N-th allocation to decrease the overhead
-d STACK_DEPTH, --stack_depth STACK_DEPTH
maximum stack depth to capture
-T TOP, --top TOP display only this many top allocating stacks (by size)
-z MIN_SIZE, --min-size MIN_SIZE
capture only allocations larger than this size
-Z MAX_SIZE, --max-size MAX_SIZE
capture only allocations smaller than this size
EXAMPLES:
EXAMPLES:
...
@@ -147,7 +190,16 @@ EXAMPLES:
...
@@ -147,7 +190,16 @@ EXAMPLES:
allocations every 5 seconds
allocations every 5 seconds
./memleak.py -p $(pidof allocs) -t
./memleak.py -p $(pidof allocs) -t
Trace allocations and display each individual call to malloc/free
Trace allocations and display each individual call to malloc/free
./memleak.py -p $(pidof allocs) -a -i 10 Trace allocations and display allocated addresses, sizes, and stacks every 10 seconds for outstanding allocations ./memleak.py -c "./allocs" Run the specified command and trace its allocations ./memleak.py Trace allocations in kernel mode and display a summary of outstanding allocations every 5 seconds ./memleak.py -o 60000 Trace allocations in kernel mode and display a summary of outstanding allocations that are at least one minute (60 seconds) old
./memleak.py -ap $(pidof allocs) 10
Trace allocations and display allocated addresses, sizes, and stacks
every 10 seconds for outstanding allocations
./memleak.py -c "./allocs"
Run the specified command and trace its allocations
./memleak.py
Trace allocations in kernel mode and display a summary of outstanding
allocations every 5 seconds
./memleak.py -o 60000
Trace allocations in kernel mode and display a summary of outstanding
allocations that are at least one minute (60 seconds) old
./memleak.py -s 5
./memleak.py -s 5
Trace roughly every 5th allocation, to reduce overhead
Trace roughly every 5th allocation, to reduce overhead