finding memory leaks with mdb and loading libumem


we can take advantage of LD_PRELOAD and UMEM_DEBUG flags to get memory leaks caused by malloc/free function calls.mdb is useful in this situation.

Using mdb and loading libumem we can find running process memory leaks.

(1) set LD_PRELOAD=libumem.so ,UMEM_DEBUG=default

(2) run your process, note down its processID

(3) gcore 1090
( 1090 is processID and gcore generate core.1090 file)

(4)mdb core.1090
(use this command to open mdb)
check libumem.so.1 is loaded properly (u can use ::load libumem.so command)

(5) Once mdb loaded use "::findleaks" command to find memory leaks.
(::findleaks -dvf) use this options to see complete stack trace.


source:

http://blogs.sun.com/pnayak/entry/finding_memory_leaks_within_solaris.