Using Valgrind to Profile KDE Plasmoids

During the past days I prepared my KDE Weather Ion for wetter.com for inclusion in the KDE Trunk. Before entering the review phase, the KDE people are asking for a memory leak analysis of the new code using Valgrind. That’s easier said than done as I could not really find some documentation on how to run a Plasmoid (along with its data sources) through Valgrind…

After a little bit of googling I finally figured out how to do this and would like to use this post to document my findings.

Well, the key to the solution lies in a neat tool called plasmoidviewer, which can be used to run a Plasmoid as a standalone application. From that point on, things get easy: Just run Valgrind on plasmoidviewer along with the desired Plasmoid and you are done, such as in (this example will run the leak check on the Weather Plasmoid):

valgrind --tool=memcheck --leak-check=full plasmoidviewer weather