Memory debugging with refdbg

Existing statistics

You can find some existing statistics here. Feel free to add statistical information to this page.

Get yourself a special type of glib

export CVSROOT=:pserver:anonymous@anoncvs.gnome.org:/cvs/gnome
cvs -z3 co glib
cd glib
./autogen.sh --disable-visibility --prefix=/opt/glib-dbg --enable-gc-friendly --disable-mem-pools
make
sudo make install

Install refdbg

You can find it it here. Install it in /opt/refdbg

Using refdbg on poor tinymail

export LD_LIBRARY_PATH=/opt/glib-dbg/lib:$LD_LIBRARY_PATH
export G_SLICE=always-malloc
export G_DEBUG=gc-friendly

Compile tinymail using minimal options:

./autogen.sh --with-html-component=none --enable-gnome=no --prefix=/opt/tinymail
make
sudo make install

Now you can do things like this for debugging reference counting

/opt/refdbg/bin/refdbg -c "r0=<TnyHeader> D:All ; addrule <TnyHeaderListModel> D:All" /opt/tinymail/bin/tinymail

Just addrule to add new types. Use <GTypeYourType> if you are adding a rule about a GType (like the tinymail ones are).

Or you can do *really* cool things like debugging GObject problems with gdb:

/opt/refdbg/bin/refdbg -c "btnum=8 ; r0=B:Error" gdb --args /opt/tinymail/bin/tinymail

You can, this way, exclude problems about types. And include problems about specific other types. Read about refdbg for more information about this. It *will* increase your productivity while debugging a lot.

Valgrinding

Realtime graph that draws the memory usage while working with the application

This is a demo of what is being explained here.

export G_SLICE=always-malloc
export G_DEBUG=gc-friendly
wget http://valgrind.org/downloads/valgrind-3.1.1.tar.bz2
tar jxvf valgrind-3.1.1.tar.bz2
cd valgrind-3.1.1
wget http://pvanhoof.be/files/project1.tar.gz
tar zxvf project1.tar.gz
cd project1
make
cd ..
patch -p0 < project1/valgrind_massif_ms_main.diff
./autogen.sh --prefix=/opt/valgrind
make
sudo make install

And now run project1/src/project1 and press "Go"

Normal valgrind

Or just use valgrind like this (you will not have the live memory-usage statistical graph being redrawed while you're using tinymail):

/opt/valgrind/bin/valgrind --tool=massif /opt/tinymail/bin/tinymail 

When you close the tinymail demo-ui, you'll have a massif.$NUM.ps file in your currect directory. Rotate that one to the left in for example evince to see a graph of the memory usage during that session.

[GdbTricks]