Finding memory leaks with Valgrind
As discussed in Chapter 3, Designing Your Application with Qt Designer, you should really get in the habit of using Qt's parent-child relationship when managing the memory for the classes based on QObject in your application to avoid memory leaks. In my time of writing Qt applications, the only time I've had to deal with memory leaks was when I didn't use memory management based on QObject. In addition, using classes such as QSharedPointer for pointers that aren't based on QObject is a good idea too.
Sometimes, though, you might introduce a memory leak that you can't find on your own. In that case, a tool such as Valgrind can be a lifesaver; it tracks every memory allocation and free operation in your application, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access