[Development] QML Demo has a higher memory usage than Wdiget Demo

Ulf Hermann ulf.hermann at qt.io
Wed Jun 15 09:47:13 CEST 2022


Hi,

> We found that QML applications occupy more than 50% more memory than Widget
> applications. We have sorted out QML demo and Widget Demo that use similar
> controls. Now we would like to consult and discuss the reason for this and
> whether there is an optimization plan.

This is a rather coarse statement. In order to optimize something we 
first have to figure out where exactly the memory is used.

My first question would be how you have measured the memory usage. 
Measuring memory usage is not trivial after all. For example, in QML we 
use mmap() to map compilation units from disk into memory. In case of 
memory pressure, they will be transparently paged in and out by the OS. 
Therefore we do not take special care to aggressively unmap them 
manually. Does this count as memory usage?

Second, you are using Qt Quick Controls 1. This is known to be 
inefficient. You should use Qt Quick Controls 2 instead.

The general direction for optimization of QML is to compile to C++ ahead 
of time. In order to do so, you have to use CMake and qt_add_qml_module. 
However, you won't save a lot of memory that way, yet. Only when 
qmltc-generated code will be able to directly call the C++ bindings 
generated by qmlsc we will be able to omit the byte code from the 
compilation units and (optionally) drop the interpreter and JIT from QtQml.

best regards,
Ulf Hermann


More information about the Development mailing list