[Development] Releasing memory after clear() in Qt containers (Qt 5.X)
giuseppe.dangelo at kdab.com
Sat Apr 24 16:57:15 CEST 2021
On 24/04/2021 01:41, Kevin Kofler via Development wrote:
> This particular issue has come up so frequently in the last few weeks that
> this behavior change in Qt 6 sounds like a major design flaw of the Qt 6
> QHash to me. Also because it subtly breaks source compatibility in a way the
> compiler cannot possibly detect, with the worst possible outcome (undefined
> behavior). Only a sophisticated static analysis tool has any chance of
> catching this, if a dedicated check is written.
The tradeoff is a much faster QHash (and much less allocation-intensive)
if you're using it for pure storage; OA has some nice performance
benefits, see the Tessil/ABSL's benchmarks.
In general, try to avoid using the Qt containers if you care about
algorithmic or behavioural guarantees (and you're not willing to revisit
and fix the code every now and then, especially in major version
upgrades). Use them for the convenience APIs. Yes, I know, it's
tremendously easy to depend on some of these guarantees "by accident" --
Hyrum's law is real, after all.
My 2 c,
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4329 bytes
Desc: S/MIME Cryptographic Signature
More information about the Development