@Christian-Ehrlicher said in How avoid memory leak with GUI programming:
@TheEnigmist said in How avoid memory leak with GUI programming:
VS points to p = p.scaled line that add every time 10k byte of data (50x50x4 bytes), and each time I create and detroy the widget where that QAbstractTableModel is I see in memory that all that Pixmap are never destroyed.
There is no leak and can't be one - you should take a look into QPixmapCache and for the sake of performance and implicit sharing don't load the pixmap in your data() method every time.
Yeah I just found out that I was really wrong with that :( I will fix it right now!
So I can go over when see pixmap in my allocated memory due to QPixmapCache. Ofc is always better to improve my code and don't load so many times a pixmap!
@Chris-Kawa said in How avoid memory leak with GUI programming:
@TheEnigmist said in How avoid memory leak with GUI programming:
So if I'm not wrong what is cached is not the file on disk, but its scaled version
No. How would Qt know that it's the same pixmap? What's cached is the pixmap that you create from a file, and the path (with some additional info) becomes a key to look it up in the cache.
I see, but why the debugger points me to the scaled() function when looking for the allocated memory istance?