Debug with memory leak
· One min read
find memory leak of a running process
cat /proc/$pid/smaps
-
find out the
PID
of the processps -aux
-
capture
/proc/PID/smaps
and save into some file likebefore_meminc.txt
-
wait till memory gets increased
-
try again step 2
-
find the difference between first
smaps
and 2ndsmaps
, e.g. withdiff -u before_meminc.txt after_meminc.txt
-
note down the address range where memory got increased
-
use
pstack
andwatch
command to get the right call stackwatch -n 1 'pstack $PID | tee -a $PID.stack'
C-c
when we caputred right stack -
check our stack file, find the functions between address range which we got from step 6.