Saturday, February 11, 2006

Massif for memory profiling

So you might have noticed that your application is using a bit of memory, but it wasn't *that* much so your didn't worry about it too much. Then one day maybe you noticed your app was using more memory then Konq and you don't have a leak. What do you do? Use a heap profiler.

You have probably used KCachegrind to improve performance, but did you know that Valgrind includes a heap profiler too? Check out the massif documentation which should get you started. I have found a Gnome massif tutorial that provides a walkthrough of a gnome application and most everything applies to KDE applications too.

KDE 3.5.1 is better then ever, but there are still applications that use way to much memory. On my system I regularly find Konversation and Akregator using more memory then KMail and Konq combined. I profiled them both and found some interesting results while exploring what massif can do.

Applications that use a little amount of memory matter too. I profiled a small Qt4 application I have today and was able to save a few MB after just a few small changes. Small savings really do add up and are important. Recently in Jim Getty's blog he has talked a number of times about how the $100 laptop will have 128MB of ram total for the system, desktop *and* running application. Recently he discussed how the gnome-clock-applet was using more then 60 megabytes. With the conversion to Qt4 KDE applications are in the perfect opportunity to show that KDE can be really light. Running the most basic KDE3 application uses more then twice the memory (total including libs) of some Qt4 example application's I tried. Just migrating to use Qt4, KDE applications should get a nice drop in memory size. But that is just the beginning, just like you take time to speed up your application with KCachegrind so should you profile your memory usage from time to time. And if you refractor your application while porting it to Qt4 take a minute to see if you can decrease the memory requirement. Many systems today still ship with only 256MB. KDE applications are in fantastic shape and we will be getting better in the next year and with tools like massif we will have no problem providing a desktop and applications with a low memory footprint.

No comments:

Popular Posts