Normally, running valgrind is a matter of either:

valgrind --tool=memcheck --num-callers=50 --leak-check=yes myprog

Or:

valgrind --tool=massif --depth=50 --format=html myprog

Former reports memory leaks and latter generates a postscript graph of the memory usage and a HTML report of the stacktraces leading to them.

However, some programs on the GNOME desktop are hard to get into because they start up automatically. Here are some tips:

  • nautilus, gnome-panel: These start up from gnome-session. Here is what you need to do:

    • gnome-session-properties

    • Go to the Current Session tab
    • Click on the program you want to profile in the list box
    • Set Style to Normal (it will be Reset now)
    • Click Apply
    • killall program-name

      • VincentUntz: It's easier to do gnome-session-remove program-name instead of all those steps.

    • valgrind program-name &> vg

    • To exit the program, hit ctrl+c to abort. It will restart and set itself back to normal
  • Bonobo type stuff: these are processes started up by Bonobo. You can list these with ps aux | grep oaf-activate | grep -v grep.

    • Find the .server file. Try locate .server

    • You will see something like
      <oaf_info>
        <oaf_server iid="OAFIID:GNOME_SettingsDaemon"
                    type="exe" location="/opt/gnome/lib/control-center-2.0/gnome-settings-daemon">
          <oaf_attribute name="repo_ids" type="stringv">
            <item value="IDL:Bonobo/Unknown:1.0"/>
            <item value="IDL:GNOME/SettingsDaemon:1.0"/>
          </oaf_attribute>
        </oaf_server>
      </oaf_info>

      You want to take the thing that is in location and make a shell script that looks like this:

      exec valgrind /opt/gnome/lib/control-center-2.0/gnome-settings-daemon "$@" &> my-file

      Then replace the location with the location of the shell script.

      • KjartanMaraas: most of these binaries were moved to $prefix/libexec some time ago...

    • Now killall bonobo-activation-server and also killall gnome-settings-daemon (replace with the program you are looking at, as needed).

Initiatives/MemoryReduction/Tools/GetValgrindInToughPlaces (last edited 2013-11-22 21:16:20 by WilliamJonMcCann)