KDE vs XFCE in terms of memory usage
For the moment I have to cope with a low-memory machine at home, so I decided to switch it from KDE to XFCE. But is it really worth it, in terms of memory savings? I decided to measure…
First of all, I’m not trying to do rigorous analysis here but just do some estimates to make a decision for personal use. Still, if you find something in my method which invalidates the results I obtained, I’d be glad to know about it.
To know the memory consumption of each desktop system, I simply started a fresh session in that desktop, opened a terminal and obtained a process listing with ps -e. No other program was opened at the time. Because I did this using a new user account, the test was made with the default configuration and default loaded programs of each desktop system.
Since the important figure in the ps output is the RSS (resident set size) column, I also turned off the swap partition in my computer. The ps manpage says that the RSS field doesn’t count swapped memory from the process. Good thing I noticed this before it was too late!
Here is the result for KDE:
| program | vsz | rss |
| Xorg | 23,936 | 18,304 |
| kded | 35,608 | 16,136 |
| kdesktop | 33,452 | 15,200 |
| konsole | 33,512 | 14,540 |
| kicker | 34,888 | 14,388 |
| korgac | 33,520 | 12,788 |
| kwin | 30,520 | 11,628 |
| kpowersave | 30,792 | 11,024 |
| knotify | 36,400 | 10,688 |
| klipper | 28,456 | 9,652 |
| ksmserver | 27,124 | 8,368 |
| artsd | 22,452 | 8,168 |
| kaccess | 27,212 | 8,028 |
| seahorse-agent | 20,828 | 6,608 |
| klauncher | 27,476 | 6,324 |
| kio_file | 26,048 | 5,376 |
| gconfd-2 | 6,692 | 3,736 |
| bash | 6,368 | 3,728 |
| kdeinit | 25,764 | 3,516 |
| dcopserver | 25,616 | 2,916 |
| startkde | 4,300 | 1,492 |
| gam_server | 3,108 | 1,408 |
| ssh-agent | 4,508 | 724 |
| dbus-daemon | 2,760 | 532 |
| kwrapper ksmserver | 1,692 | 364 |
| dbus-launch | 2,916 | 340 |
| total | 555,948 | 195,976 |
And here is the result for XFCE:
| program | vsz | rss |
| Xorg | 27,776 | 20,788 |
| gnome-terminal | 43,652 | 16,860 |
| xfdesktop | 57,172 | 14,848 |
| update-notifier | 24,996 | 14,480 |
| xfce4-panel | 20,580 | 12,340 |
| notification-daemon | 19,156 | 10,224 |
| xfce4-session | 18,016 | 10,092 |
| xfwm4 | 16,216 | 8,344 |
| xfce4-menu-plugin | 15,780 | 7,856 |
| seahorse-agent | 20,864 | 6,772 |
| xfce-mcs-manage | 18,812 | 6,148 |
| gnome-volume-manager | 18,108 | 4,744 |
| Thunar | 13,880 | 4,472 |
| gconfd-2 | 6,692 | 3,776 |
| bash | 6,412 | 3,740 |
| bonobo-activation-server | 15,264 | 2,892 |
| xscreensaver | 4,240 | 1,936 |
| /bin/sh /etc/xdg/xfce4/xinitrc — /etc/X11/xinit/xserverrc | 4,292 | 1,444 |
| gam_server | 3,108 | 1,408 |
| dbus-daemon | 2,760 | 892 |
| gnome-pty-helper | 2,720 | 756 |
| ssh-agent | 4,508 | 728 |
| dbus-launch | 2,916 | 440 |
| total | 367,920 | 155,980 |
So, XFCE uses 152MB of RAM, versus the 191MB KDE uses. Not bad, almost 40MB (20%) less!
That’s not the whole story, though. I also wrote down the output of the free command as a sanity check.
Using KDE:
| total | used | free | shared | buffers | cached | |
| Mem: | 256112 | 245040 | 11072 | 0 | 20832 | 138236 |
| -/+ buffers/cache: | 85972 | 170140 | ||||
| Swap: | 0 | 0 | 0 | |||
Using XFCE:
| total | used | free | shared | buffers | cached | |
| Mem: | 256112 | 251340 | 4772 | 0 | 20332 | 127156 |
| -/+ buffers/cache: | 103852 | 152260 | ||||
| Swap: | 0 | 0 | 0 | |||
Look at the “used” column, in the “-/+ buffers/cache” line. That is the actual memory amount being used by the running programs in the computer.
This is a very interesting and surprising result: at the end of the day, XFCE actually uses more memory than KDE! Why, if adding up the resident sizes of the processes from each desktop system you get a different conclusion?
One explanation would be that KDE actually shares more memory between processes than XFCE. Its programs most probably have a greater number of shared libraries in common, which enables the kernel to use the same memory pages for the text section of those libraries accross process images. Unfortunately I didn’t collect data to test that possibility, and it’s late at night now. But it makes sense.
The bottom line, surprisingly enough, is that you should stick with KDE to preserve memory. Or switch to a bare-bones window manager instead of a complete desktop system, like IceWM, Window Maker, Blackbox or something else. But I’m too spoiled by the amenities of a good desktop to do that.
By the way, the tests were made with KDE 3.5.8 and XFCE 4.4.2 under Debian GNU/Linux unstable (updated on 2008/01/06) on a 32-bit x86 machine.
Monday, January 7, 2008 at 13:17
“One explanation would be that KDE actually shares more memory between processes than XFCE. ”
You might want to read Lubos Lunak’s (kwin developer) analysis of memory usage:
http://ktown.kde.org/~seli/memory/desktop_benchmark.html
In short – yes, KDE is famed for its excellent adherence to the Once-And-Once-Only ( http://en.wikipedia.org/wiki/Don‘t_repeat_yourself ) philosophy, with huge amounts of functionality crammed into shared libraries, resulting in apps that have a smaller Lines of Code count and just much less duplication and more efficiency in general.
Monday, January 7, 2008 at 23:44
Thanks for the link, that’s very interesting read indeed.
It seems my method for evaluating memory use is even lamer than I thought it was.
And Lubos got quite different results for the “plain desktop” case, which was what I was trying to measure. But he was using an older XFCE version, maybe things changed in that project since then…
About using lots of shared libraries, it’s good from the memory usage and code reuse perspective, but the downside is that it’s lots of work for the dynamic linker and can have a measurable impact in program loading, as shown by Ulrich Drepper:
http://people.redhat.com/drepper/dsohowto.pdf
Prelinking can help, but not if libraries are dlopened (I don’t know if KDE uses dlopen very much).