Memory GN-Optimization tools, (mallocfree.d vs gconfd-2)
Tuesday May 31, 2005
Memory optimization also came up in Robert Loves GUADEC 6 talk. I already looked at pmap, but I promised BenM and Yusuf that I would write a quick tutorial on using Solaris memory profiling tools for GNOME. Sure, I thought, when am I going to have time to do that? Well, in the 15 minutes before I caught the train home on friday, I found Adam Leventhal's libumem primer and SMG's dtrace script which indicate the frequency malloc and free are called for each code path. In this example, I ran the script against gconfd-2 after launching and closing gnome-calculator.
Here's the script:
# cat mallocfree.d
#!/usr/sbin/dtrace -s
pid$1::free:entry,
pid$1::malloc:entry
/execname == "gconfd-2"/
{
@[ustack(), probefunc] = count();
}
Here are the call stacks and number of calls of the top five code paths to free/malloc:
./mallocfree.d {process ID}
{stuff deleted}
libc.so.1`free
libglib-2.0.so.0.400.1`standard_free+0xc
0x80d10b8
0x1c0
0x6e622f65
free 102
libc.so.1`free
libglib-2.0.so.0.400.1`standard_free+0xc
libORBit-2.so.0.0.0`ORBit_POAObject_handle_request+0x35b
0xff0cec83
free 116
libc.so.1`free
libglib-2.0.so.0.400.1`standard_free+0xc
0xe810ec83
free 181
libc.so.1`free
free 185
libc.so.1`malloc
libglib-2.0.so.0.400.1`standard_malloc+0xc
malloc 460










