c++ - Qt memory leak using QPixmap -


I'm getting a strange memory leak somewhere in this code. The method is a slot connected to the method in another thread. It does 2 things: 1 It updates a text box as it moves, which is on the second thread 2 It updates the image shown on the GUI in the picture corresponding to that recycling.

It works great for 10-30 iterations, then it is moving upwards. Looking at its memory usage in the task manager, I can see that it is already stable, then using every instance RAM increases up to about 10%. What can I do to remove the leak?

  Infection :: Infection (CDUDATE * Parent): Q Menine (Parent), UI (New UI :: Infection) {Yuri-> Setup UI (this); This- & gt; File = files; ImageObject = new QImage (); View = New QGraphicsScene (this); } Transition: ~ infection () {delete UI; Delete ImageObject; Remove view; }  

slot in question:

  zero transition: onCounterChanged (QString counter) {ui-> ImageCounter-> Set text (counter); Folder = ui - & gt; Folder name- & gt; ToPlainText (); Int m = counter.toInt (); QString file name = files [m]; ImageObject-> Load (file name); Image = QPixmap :: fromImage (* imageObject); View- & gt; clear (); // It decides that the leaking scene-> Junk Pixmap (Image); UI- & gt; PicDisplay-> SetScene (view); UI- & gt; PicDisplay-> FitInView (image.rect (), QT :: IgnoreAspectRatio); }  

I think you do not only update your image, but new Scene with pixmap items can be created:

  Zero transition: onCounterChanged (QString counter) {[...] imageObject- & gt; Load (file name); Image = QPixmap :: fromImage (* imageObject); Scene-> AddPixmap (image); // & lt; ----- Adds new pixmap items to this view [..]}  

So, after 10-30 iterations you have 10 to 30 pixels items that are visible on your view Are there. I suppose you have to update the QGraphicsPixmapItem :: setPixmap () function using the existing QGraphicsPixmapItem instead of creating a new one on each walk.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -