Search code examples
c++qtmemoryqlist

Qlist suitable for use in service?


I am creating a C++ program that will run as a service (under linux), and I'm using Qt because of the numerous handy methods. I'm using a QList to track items that will add to, and remove from, the qlist over many months. (With potentially hundreds of additions/removals per day).

Based on my recent reading, it appears that QList's never shrink - they only grow in terms of memory usage (until the entire QList is deallocated). Does that make a QList unsuitable for use in an app that runs indefinitely?

Will I have to create my own linked list instead? Or is there a way to "shrink"/cleanup the memory used in a QList?


Update: Based on feedback below is QLinkedList is preferable? (Does it immediately release memory when a member of the list is "erased")


Solution

  • Qt has it's own QVector and QLinkedList

    QVector has a squeeze function that releases unused memory when needed