The mumblings of a Christian autistic husband, dad, IT guy and amateur radio operator - Will Brokenbourgh / AF7EC
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'.
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.
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!
X11 Xaw (X Athena widgets)
Shown is a window created with X11 Athena widgets. As shown in the image, the RAM usage was a measily 2.4 MB.
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 used 9.8 MB of RAM to display a plain window.
Tcl/Tk used 9.8 MB of RAM to display a plain window -- a tie with SDL.
Fox toolkit used 10.4 MB of RAM to display a plain 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 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.
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.
Using the generic 'Graphical' project choice, a plain window in Gambas 3 uses 21 MB of RAM.
OpenJDK (Java) 7
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 used 35.1 MB of RAM to display a plain 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!
• 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.