[Development] Releasing memory after clear() in Qt containers (Qt 5.X)

Francesc Martinez francescmm at gmail.com
Fri Apr 23 19:00:42 CEST 2021


Hi all,

I have some doubts regarding the memory management in Qt, specially about
containers and how the COW affects the release of memory.

I'm doing some research in GitQlient and I've noticed that the RAM memory
used doesn't decrease at all when it's supposed to. In there I'm managing
an internal cache (needs some improves, I know) that stores the commit
information in a QHash<QString, CommitInfo>
<https://github.com/francescmm/GitQlient/blob/master/src/cache/GitCache.h>
(ignore the QVector<CommitInfo*> since it just stores the references to the
QHash[sha] for optimization).

I fill the hash on load and clear it when I close the repo (already ensure
about it with logs and debugging). And the confusing thing is that the
memory doesn't decrease at all. So, if I keep opening and closing the same
repo, the memory used keeps increasing.

Do you know if there is any internal mechanism that causes that? Or is just
the way the OS acts about memory management?

I can setup a branch with the changes so barely no widgets are created to
facilitate the use case, if needed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20210423/a6731444/attachment.html>


More information about the Development mailing list