I use this code in order to capture the color of a pixel, compare it with a HTML value and do an action if the comparisono is successful
while(1){
sleep(3000);
*img = a->toImage();
QRgb b = img->pixel(796,554);
c->setRgb(b);
qDebug() << c->name();
delete a;
delete c;
if(c->name() == "#968d82"){
system("canberra-gtk-play -f ~/Documents/Alert.wav");
}
while(1){
sleep(3000);
QPixmap *a = new QPixmap;
*a = QPixmap::grabWindow(QApplication::desktop()->winId());
QImage *img = new QImage;
*img = a->toImage();
QRgb b = img->pixel(796,554);
QColor *c = new QColor;
c->setRgb(b);
qDebug() << c->name();
delete a;
delete c;
if(c->name() == "#968d82"){
system("canberra-gtk-play -f ~/Documents/Alert.wav");
}
To copy to clipboard, switch view to plain text mode
Every time it goes through the loop the program takes almost 4MB of memory usage 


It's probaly because it grubs the whole desktop picture every time it runs...
I tried to free some by deleting 'a' and 'c' but it didn't work. Any suggestion?
Bookmarks