How to minimize Qt program memory usage
-
wrote on 29 Sept 2013, 14:24 last edited by
HI, I found that just an empty window of Qt GUI application takes 4.8M memory. Could I minimize these memory usage? I am pretty new to Qt and currently using Qt Creator to program. Thank you very much!
-
wrote on 29 Sept 2013, 15:18 last edited by
The 4.8 MB are an exe compiled with debug options?
Release compiled version are in general much smaller than a debug compilation. Furthermore, you can check memory optimization of your compiler. AFAIK all compiler have one or in another to decide whether to optimize for memory usage or for speed. However, those options are only available in release mode compilations. -
wrote on 29 Sept 2013, 23:40 last edited by
Thanks for reply. The released exe file are only 308 KB. But take 4.8MB memory when it starts. The program is just an empty window. Could you tell me which compiler option can optimize the memory usage? Thanks.
-
wrote on 30 Sept 2013, 08:26 last edited by
Hi wenc,
The program in memory will take it's executable size, plus the size of dynamic libraries needed (QtCore, QtGUI, etc.).
To lower your memory usage, in addition to what koahnig said, be sure to avoid including unnecessary libraries, and use the configuration step to remove unwanted parts of Qt. Removing unwanted Qt parts can lower Qt libraries size by 50%.Qt source ships a small configuration tool called qconfig, that visually displays selectable parts of libraries, and let you remove the ones you do not want. It will generate a c++ header file, that can be used with the -qconfig <config_file> flag, during configuration.
You can also save those -no-xxx flags in your platform mkspec. -
wrote on 30 Sept 2013, 10:39 last edited by
Thanks, Adrien. I opened qconfig which asked for Qt Features file. I don't know where to find it and couldn't find related documents of qconfig. Could you give an example? I would appreciate it. Thanks.
-
wrote on 30 Sept 2013, 10:56 last edited by
I found the document in here http://qt-project.org/doc/qt-4.8/fine-tuning-features.html. Thank you for the informations!
-
wrote on 30 Sept 2013, 11:52 last edited by
Yes that's the one. I repost the URL as yours has a trailing dot, leading to a 404.
"Qt 4.8 Fine tuning feature":http://qt-project.org/doc/qt-4.8/fine-tuning-features.html
Glad to help :)
1/7