Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Quick memory usage

Tags:

qt-quick

qml

Working on a medium size Qt project we've noticed, that memory consumption is surprisingly high when there is not much going on on the screen. My attempts to find some kind of memleak led me to CREATE_QML_OBJECT macro, where qml instance objects are created. After removing all custom ui elements from loaded qml file and leaving just four basic ones I got

Rectangle {
    Button {}
    CheckBox {}
    Slider {}
    TextField {}
}

And this thing consumes about ~1-1.5 MB.

I've had a look at QtQuick demo projects and its the same thing there:

Gallery demo. Just a bunch of controls, 100 MB on startup.

Same game demo. Simple game, after 5 mins of playing 256MB are gone.

I'm really surprised by the fact that a simple QtQuick QML application can eat enormous amount of memory. Does anybody know what causes this allocations and is there a way to manage it?

Any help will be greatly appreciated.


Related links, haven't found an answer there

QML big memory consumption?

Memory footprint of QML applications

Performance Considerations And Suggestions

like image 291
vim Avatar asked Aug 27 '14 13:08

vim


1 Answers

Its all managed by javascript garbage collector. Few thing to try are:

1)Call gc() just after loading an item i.e. on Component.onCompleted:

2) Load the items on Loader. This way, they should not stay in memory when not is use.

These do not guarantee reducing memory footprint but can help a bit.

like image 93
Aman Avatar answered Sep 22 '22 02:09

Aman