NOTE: This is an older article, so the information provided may no longer be accurate.

Comparison of graphical toolkit resource usage

My Mom might ask "What is a graphical toolkit?"
A graphical toolkit is a collection of software that helps programmers like me make computer programs faster and easier than 'reinventing the wheel' and making my own. This software allows you to create windows, buttons, lists and other graphical elements much easier than doing it 'from scratch'.

I'm one of those nuts who like to use the bare minimum of resources when computing. Because of this, I've paid close attention to how much RAM and other resources GUI toolkits use when programming. Some people just don't care how much RAM and CPU cycles the apps on their computer use up, but I'm not one of them.

I have a decent computer with a decent Intel processor, my OS is FreeBSD, with 8 GB of RAM and plenty of hard-disk space. My graphics card is decent, as well. But I'm very sensitive to how long things take to happen when using programs, and if it seems too laggy or slow, I look for ways to speed it up, or find a faster/lower-resource alternative.

Sometimes the subject comes up in online discussions about how 'lightweight' a certain toolkit is. When 'lightweight' is mentioned in the same breath as Qt or GTK 3, my eyebrow usually goes up like Spock. I want to share my knowledge with those folks, but don't usually have anything ready-made. Well, here it is, ready-made and a good demonstration of how some toolkits just cannot be truly called 'lightweight'.

 

God loves geeks too!
Why Jesus?

The comparison
Let me say right now, this is NOT a scientific comparison, but even so, the differences are pretty clear. I created just a plain window in each of the major toolkits on Debian Linux (8 / Jessie and also 9 / Stretch). The RAM usage and processor usage is shown by using the LXDE task manager. The RAM usage is the 'real' measurement, not the virtual memory amount. Toolkits are listed from lightest to heaviest as far as RAM usage.

X11 Xlib
X11 Xlib window
The lightest-weight in my test was a window created with just Xlib. As shown in the image, the RAM usage was a tiny 1.6 MB! Now that, my friends, is lightweight!
(added 2017-06-19)

X11 Xaw (X Athena widgets)
X11 Xaw window
Shown is a window created with X11 Athena widgets. As shown in the image, the RAM usage was a measily 2.4 MB.

FLTK 1.3.3
FLTK 1.3.3 window
Next up is FLTK 1.3.3. It used just 6.3 MB to display a plain window. Not bad! And FLTK is, in my opinion, much easier to use than X11 Athena widgets.

SDL (not SDL2)
SDL plain window
SDL used 9.8 MB of RAM to display a plain window.
(added 2017-06-19)

Tcl/Tk
Tcl/Tk window
Tcl/Tk used 9.8 MB of RAM to display a plain window -- a tie with SDL.
(added 2016-12-14)

Fox toolkit
Fox toolkit window
Fox toolkit used 10.4 MB of RAM to display a plain window.
(added 2016-12-14)

GTK 2
GTK 2 window
GTK 2 has been a graphical toolkit workhorse for many years now. Now deprecated in favor of GTK 3, GTK 2 only used 11.4 MB of RAM to display a plain window.

GTK 3
GTK 3 window
GTK 3 is the current version of GTK. In my opinion, it's not a desirable toolkit to work with due to frequently-changing API. It's like coding for a moving target. In my test, it consumed 17.3 MB just to display a plain window. That's about 6 MB more compared to GTK 2. Kind of bloaty, if you ask me.

Qt 4
Qt4 window
Next on our list is Qt 4. Qt 4 has also been somewhat of a workhorse in recent years, but is now deprecated in favor of Qt 5. Qt 4 was at the base of the popular KDE desktop environment for a while. In this test, Qt 4 consumed just a bit more than GTK 3 did -- 18.5 MB to produce a plain window.

Gambas 3
Gambas3 window
Using the generic 'Graphical' project choice, a plain window in Gambas 3 uses 21 MB of RAM.

OpenJDK (Java) 7
OpenJDK(Java) 7 window
Yeah, yeah, I know, you can't really call Java a graphical toolkit, but I thought I'd throw it into my test, just for fun. RAM usage for producing a plain window sits between Qt 4 and Qt 5 -- 37.5 MB.

SDL2
SDL2 window
SDL2 used 35.1 MB of RAM to display a plain window.
(updated 2017-06-19)

Qt 5
Qt5 window
Qt 5 has surpassed Qt 4 as the recommended Qt toolkit and also surpasses Qt 4 in RAM usage -- 43.2 MB to create just a plain window, which makes it the heaviest-weight graphical toolkit in this test. Pretty bloated!

Again, this isn't an exacting, scientific test, but it does give you a better idea how lightweight or heavyweight your favorite graphical toolkit is. And results are always going to be slightly different based on 32 or 64 bit OS's, different Linux or *BSD distros and so-on. I think, though, that no matter where you run these toolkits, their RAM usage will be similar to what is shown here.

This test wasn't to try to convince you to give up your favorite toolkit, but is just for information only. It's a lot like real tools -- some are bulky and difficult to use, some are lightweight and well designed -- but each tool serves a purpose and will usually get the job done when others cannot.

God bless you, and thank you for reading! big grin

Updated 2016-12-14 to add Fox toolkit, SDL2 and Tcl/Tk examples.
Updated 2017-06-19 to add SDL, Xlib and updated SDL2's memory use.
Updated 2017-09-12 to add Gambas 3.

 

 

Comments

LM posted on 2016-12-02
Great comparison. FLTK was pretty much where I thought it would be, but was surprised by a few of the other results. Would be curious where Fox Toolkit and SDL come out on those tests. I'm guessing FLTK is lighter than FOX Toolkit as well.

I've been trying to locate useful applications for FLTK, SDL and PDCurses (with SDL backend) because they're a lot lighter and perform better than many of the alternatives out there. I've found some interesting programs, but always looking for more to replace programs that use heavier GUIs.

Thanks again for sharing your comparison. It's a great way to illustrate some of the differences in the GUI frameworks.

Will B posted on 2016-12-02
Thank you for your comment! I may add Fox and SDL in the future.
Herberth posted on 2017-09-07
Regards, your very good comparison.

I programmed in Gambas3 and did not show a window created with Gambas3.

A window created with Gambas3 used only 5.4 MB to display a simple window.

Not bad! Much better.

Please add for the next gambas3

Will B posted on 2017-09-12
Thanks! I have posted a Gambas3 entry.

My RAM usage was different than yours by quite a bit, so maybe Gambas3 differs from distro to distro.

 

Post A Comment

Your name:

Your e-mail address: (Will not be seen or used by anyone else but me)

To help cut down on spam, what do you get when you add two and four?:

Please type your message below: (Please limit message to less than 1,000 characters)

By submitting your comment, you consent to me posting it on my site.

All submissions are moderated before being posted and any profanity or sensitive information blanked out.

My Story   |   Today God is First!   |   Autism
 
This page should pass HTML validation. Standards-compliance is important to me.