I meet a troublesome bug about memory usage, so I want to use Dtrace to check malloc and free on Solaris 10.
I use the following command
dtrace -l | grep malloc
The output is:
7000 fbt unix prom_malloc entry
7001 fbt unix prom_malloc return
7141 fbt genunix cacl_malloc entry
7142 fbt genunix cacl_malloc return
12319 fbt genunix rmallocmap_wait entry
12320 fbt genunix rmallocmap_wait return
13078 fbt genunix rmalloc_wait entry
13079 fbt genunix rmalloc_wait return
13526 fbt genunix rmallocmap entry
13527 fbt genunix rmallocmap return
16846 fbt genunix rmalloc entry
16847 fbt genunix rmalloc return
25931 fbt tmpfs tmp_memalloc entry
25932 fbt tmpfs tmp_memalloc return
It seems there is no malloc.
I have checked Solaris Internal, and found the malloc calls sbrk. So I use the following command:
dtrace -l | grep sbrk
But there is nothing found.
So how can I use Dtrace to check malloc on Solaris 10?
There are various tools that already implement the logic required to identify memory leaks under Solaris,
UMEM_DEBUG=default UMEM_LOGGING=transaction LD_PRELOAD=libumem.so.1thenmdb's ::findleaks)check -leaks)Should you still want to go the
dtraceway, you need to trace the process you suspect to leak memory using the pid provider. You searched the kernel probes withdtrace -land found nothing but this is expected as the kernel does not implementmallocorbrk. They are userland functions located in the C standard library.This script will trace every
mallocandfreecalls by a program:For more in-depth examples, have a look to http://ewaldertl.blogspot.fr/2010/09/debugging-memory-leaks-with-dtrace-and.html and http://www.joyent.com/blog/bruning-questions-debugging