PDA

View Full Version : Increasing memory usage in simple QML application



axx
22nd August 2017, 15:50
Hi there,

I have some problems to understand why my (simplified) logger application increases in memory consumption. I used heaptrack to measure allocations and to track down the source of memory consumption. Closing the application seems to free memory just before closing, so that heaptrack does not show this as a leak.

The project is quite simple and based on QML with an own class derived by QAbstractTableModel providing the messages to a TableView (Qt 5.9.1, QtQuick 2.0).
In this test setup, test messages are pushed to the model in a specific frequency. If the maximum number of messages is reached, old messages are discarded.

Furthermore, I compiled the example using Visual Studio. The memory profiler of VS showed more detailed information. Two screenshots are attached where you can see that QObjectPrivate::Connection and QtPrivate::QSlotObject instances are created by every new message. It seems, they aren't freed if the item gets removed from the model.
I have no idea, if this is as expected and why this function doesn't (seem to) free memory if rows are deleted.

Can anyone help me with this? I'd appreciate any suggestions! Thanks!


Screenshots:

12568

12569

12566

Example project zipped:
12567

wysota
28th August 2017, 13:07
I don't see any memory leaks. However your code is overly complicated. Your Message class doesn't need to be derived from QObject - it could be a simple struct which would require significantly less memory.

Please check if you get similar characteristics if you don't use QML but rather display your model on a plain QTableView in the widget world.