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