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:
// Setting source and target for drawPixmap()
QRectF source
(0,
0, currPixmap
->width
(), currPixmap
->height
());
QRectF target
(0,
0, objectCameraSelectionWindow
->getDirectionImageWidth
(),
objectCameraSelectionWindow->getDirectionImageHeight());
// drawPixmap() is faster on-screen while drawImage() may be faster on
// QPainter or other devices.
painter.drawPixmap(target, *currPixmap, source);
// Setting source and target for drawPixmap()
QRectF source(0, 0, currPixmap->width(), currPixmap->height());
QRectF target(0, 0, objectCameraSelectionWindow->getDirectionImageWidth(),
objectCameraSelectionWindow->getDirectionImageHeight());
// drawPixmap() is faster on-screen while drawImage() may be faster on
// QPainter or other devices.
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:
{
// Choose the coirrect bitmap
if(direction == "left"){
currPixmap = objectCameraSelectionWindow->getImageOnLeftVideo();
}
else if(direction == "right"){
currPixmap = objectCameraSelectionWindow->getImageOnRightVideo();
}
// Setting source and target for drawPixmap()
QRectF source
(0,
0, currPixmap
->width
(), currPixmap
->height
());
QRectF target
(0,
0, objectCameraSelectionWindow
->getDirectionImageWidth
(),
objectCameraSelectionWindow->getDirectionImageHeight());
// drawPixmap() is faster on-screen while drawImage() may be faster on
// QPainter or other devices.
painter.drawPixmap(target, *currPixmap, source);
}
void RenderDirection::paintEvent(QPaintEvent *)
{
QPainter painter(this);
QPixmap* currPixmap=0;
// Choose the coirrect bitmap
if(direction == "left"){
currPixmap = objectCameraSelectionWindow->getImageOnLeftVideo();
}
else if(direction == "right"){
currPixmap = objectCameraSelectionWindow->getImageOnRightVideo();
}
// Setting source and target for drawPixmap()
QRectF source(0, 0, currPixmap->width(), currPixmap->height());
QRectF target(0, 0, objectCameraSelectionWindow->getDirectionImageWidth(),
objectCameraSelectionWindow->getDirectionImageHeight());
// drawPixmap() is faster on-screen while drawImage() may be faster on
// QPainter or other devices.
painter.drawPixmap(target, *currPixmap, source);
}
To copy to clipboard, switch view to plain text mode
As usual, any help is much appreciated.
Anirban
Bookmarks