简体   繁体   中英

Qt qml application increasing memory usage

I created an application with Qt/QML, load a qml file with QQuickView , and with this use a Loader element for change the pages(gui) inside application, and works fine, but my problem is the increase of the program memory usage (the application starts with less of 100MB, and after 1 day, the size is about 500 MB or more), I originally write and update the model of objects in Qml (javascript), but the application grows quickly, changing to create models with C++ objects, memory usage grows less but the problem is still not solved.

My model can be updated continuously (even 1 time per second), but I don't believe that be the reason of memory rises.

But with that problem come other strangers behaviors is with TableView when changes to that page, the memory rises even 10 MB, I try to free memory with gc() , but i don't get successful results, and in the change of page, the memory sometimes can rise by 1 MB.

Note: I use a Qt 5.5, and msvc 2010.

You might want to check your application for memory leaks. That sounds a little excessive, even for QML, which is not known for memory efficiency.

Keep in mind, the QML engine will over-provision and will not release memory even when that seems the logical thing to do. I've had cases of reaching gigabytes of memory usage in QML, having tens of thousands of QML objects "alive", and upon deletion of all the objects, memory usage doesn't come anywhere near the initial memory usage. The freed memory is usually a tiny amount, for example, having 1 GB of memory worth of objects, deleting all the objects frees only like 150 MB of memory. The good news is that memory will be reused, creating those objects again will push memory usage to the previous peak, not any further. So as far as memory in your application is concerned, you are set.

I don't know if that will stack with the rest of the OS processes, whether your application will release extra memory if your system runs out of ram.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM