Memory Leaks

Finding and fixing memory leaks in Ubuntu is a major step towards streamlining the platform for the widest range of devices, including the Nexus 7 and similar platforms.

Valgrind's memcheck tool is the traditional approach for this. It produces much better results though when debug symbols are present: the stack traces contain source code variable names instead of "???" and the implicated source code file names (and line numbers) are shown (instead of the lib file names).

A useful series of three of blog posts for understanding valgrind memcheck log files:

However, getting those debug symbols can be a chore: you have to figure out which packages own the linked objects, see whether there are debug packages for them, and install them (which permanently alters your system and uses up disk).

apport-valgrind

Starting in Ubuntu 13.04 Raring, the apport-valgrind binary package provides a wrapper to valgrind that does this mostly for you. On each execution (for example apport-valgrind notify-send), it:

Note: It is recommended to update your system before execution. This ensures your run time environment is consistent with the symbol packages unpacked into the sandbox DIR and therefore results in more complete stack traces from valgrind.

This blog post covers the rationale for apport-valgrind:

dbgysm and ddebs.ubuntu.com

apport-valgrind uses your current software sources (the debian archives) your system points to. That is, when looking for debug packages, apport-valgrind is limited to the archives your system already points to. Naturally, this includes the normal Ubuntu archives in which many 'dbg' packages exist, for example: libc6-dbg. Such dbg packages are created by the diverse world of package maintainers and may use different name patterns, which sometimes makes them hard or impossible to find mechanistically.

That's why ddebs.ubuntu.com exists: to automatically create a dbgsym package (for every binary package that should have one) at build time, and publish it on ddebs.ubuntu.com.

Therefore, you may want to add it to your system archives so that apport-valgrind can use dbgsym packages too. For example, you can add this to your /etc/apt/sources.list file for Raring main and universe:

deb http://ddebs.ubuntu.com raring main universe

This blog post provides some additional background on dbg and dbgsym packages and the ddebs archive:

Nexus7/Valgrind (last edited 2013-02-15 17:16:23 by knitzsche)