Hi all,

I'm writing an application which dynamically changes the picture on running video streams. The OS is debian based with X11.

The problem is a slow but surely increasing memory leak reported by process "xorg" (not by my application). A little bit googling hinted that the pixmap paiting on the video could be an issue. I tried to comment the relavant part of the code and the memroy leak disappeared. And then, I started uncommenting bit by bit. Now the whole memory leak has come down to 3 lines of code:

Qt Code:
  1. // Setting source and target for drawPixmap()
  2. QRectF source(0, 0, currPixmap->width(), currPixmap->height());
  3. QRectF target(0, 0, objectCameraSelectionWindow->getDirectionImageWidth(),
  4. objectCameraSelectionWindow->getDirectionImageHeight());
  5.  
  6. // drawPixmap() is faster on-screen while drawImage() may be faster on
  7. // QPainter or other devices.
  8. painter.drawPixmap(target, *currPixmap, source);
To copy to clipboard, switch view to plain text mode 

So, again if I uncomment this code, linux command "top" reports a disticnt memory leak, otherwise not. The code snippet is used inside the paintEvent method:

Qt Code:
  1. void RenderDirection::paintEvent(QPaintEvent *)
  2. {
  3. QPainter painter(this);
  4. QPixmap* currPixmap=0;
  5.  
  6. // Choose the coirrect bitmap
  7. if(direction == "left"){
  8.  
  9. currPixmap = objectCameraSelectionWindow->getImageOnLeftVideo();
  10. }
  11. else if(direction == "right"){
  12.  
  13. currPixmap = objectCameraSelectionWindow->getImageOnRightVideo();
  14. }
  15.  
  16.  
  17. // Setting source and target for drawPixmap()
  18. QRectF source(0, 0, currPixmap->width(), currPixmap->height());
  19. QRectF target(0, 0, objectCameraSelectionWindow->getDirectionImageWidth(),
  20. objectCameraSelectionWindow->getDirectionImageHeight());
  21.  
  22. // drawPixmap() is faster on-screen while drawImage() may be faster on
  23. // QPainter or other devices.
  24. painter.drawPixmap(target, *currPixmap, source);
  25. }
To copy to clipboard, switch view to plain text mode 

As usual, any help is much appreciated.
Anirban