Hi,

On Tue, Jan 09, 2024 at 09:49:04PM +0100, [email protected] wrote:
> I'm using rxvt-unicode-9.31, with a background image with focus_fade. This
> shows my background the way I like it, but it slowly eats all the memory
> until it starts swapping.
> 
> Digging around I seem to have found the issue (if I understand it
> correctly): in rxvt_img::muladd an image cc is composed, and based on that
> another image cc2 is composed. That image cc2 gets used, but cc and its
> pixmap are kept hanging around and it never gets freed/destroyed.
> That results in a memleak the size of my backgroundpic every muladd is
> called = every time the focus on my terminal window changes.
> 
> Explicitly destroying cc->destimg at the end of muladd fixed the leak for
> me.

thanks for the report. Your analysis is spot on, but the fix is not
complete because the rxvt_img object is still leaked. The attached
patch should address that.

Emanuele
diff --git a/src/rxvtimg.C b/src/rxvtimg.C
index 74b46bc5..971c6394 100644
--- a/src/rxvtimg.C
+++ b/src/rxvtimg.C
@@ -608,7 +608,8 @@ rxvt_img::muladd (nv mul, nv add)
 {
   // STEP 1: double the image width, fill all odd columns with white (==1)
 
-  composer cc (this, new rxvt_img (d, format, 0, 0, w * 2, h, repeat));
+  rxvt_img *img = new rxvt_img (d, format, 0, 0, w * 2, h, repeat);
+  composer cc (this, img);
 
   // why the hell does XRenderSetPictureTransform want a writable matrix :(
   // that keeps us from just static const'ing this matrix.
@@ -639,7 +640,7 @@ rxvt_img::muladd (nv mul, nv add)
   // a 2x1 filter would obviously suffice, but given the total lack of specification
   // for xrender, I expect different xrender implementations to randomly diverge.
   // we also halve the image, and hope for the best (again, for lack of specs).
-  composer cc2 (cc.dstimg);
+  composer cc2 (img);
 
   XFixed kernel [] = {
     XDoubleToFixed (3), XDoubleToFixed (1),
@@ -658,6 +659,8 @@ rxvt_img::muladd (nv mul, nv add)
 
   XRenderComposite (cc.dpy, PictOpSrc, cc2.src, None, cc2.dst, 0, 0, 0, 0, 0, 0, w * 2, h);
 
+  delete img;
+
   return cc2;
 }
 
_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/mailman/listinfo/rxvt-unicode

Reply via email to