From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sharaf Zaman Newsgroups: gmane.emacs.bugs Subject: bug#51354: [PATCH] Fix a memory leak in pgtk_draw_fringe_bitmap Date: Sat, 23 Oct 2021 14:34:48 +0000 Message-ID: <87pmrvbyif.fsf@sdf.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5236"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.15; emacs 29.0.50 To: 51354@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 23 18:27:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1meJrU-0001BD-Lo for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Oct 2021 18:27:12 +0200 Original-Received: from localhost ([::1]:50886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1meJrS-0007lH-Nd for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Oct 2021 12:27:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meJrL-0007kw-1L for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 12:27:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1meJrK-00018Y-PL for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 12:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1meJrK-0000X0-KF for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 12:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sharaf Zaman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Oct 2021 16:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51354 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16350064011997 (code B ref -1); Sat, 23 Oct 2021 16:27:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Oct 2021 16:26:41 +0000 Original-Received: from localhost ([127.0.0.1]:37030 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1meJqv-0000Vx-Ml for submit@debbugs.gnu.org; Sat, 23 Oct 2021 12:26:41 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:40506) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1meIC9-0003xI-5i for submit@debbugs.gnu.org; Sat, 23 Oct 2021 10:40:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meIC8-0005dc-UC for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 10:40:24 -0400 Original-Received: from mx.sdf.org ([205.166.94.24]:58728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meIC6-0006Zc-Q5 for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 10:40:24 -0400 Original-Received: from localhost (207.148.31.194.vultr.com [207.148.31.194] (may be forged)) (authenticated (0 bits)) by mx.sdf.org (8.15.2/8.14.5) with ESMTPA id 19NEYqh7016868 for ; Sat, 23 Oct 2021 14:34:54 GMT Received-SPF: pass client-ip=205.166.94.24; envelope-from=shzam@sdf.org; helo=mx.sdf.org X-Spam_score_int: 21 X-Spam_score: 2.1 X-Spam_bar: ++ X-Spam_report: (2.1 / 5.0 requ) BAYES_20=-0.001, HOSTED_IMG_MULTI_PUB_01=2.137, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 23 Oct 2021 12:26:36 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:218002 Archived-At: --=-=-= Content-Type: text/plain Hello! I discovered that there's a memory leak in the pgtk code, if the windows are created/destroyed/moved/shrunk/widened frequently. I've verified it with profiler that this indeed is the location (https://i.imgur.com/LnrgGyj.png) and fixed it (https://i.imgur.com/zdgnn5K.png). PS: This is my first time sending a patch, I'm not 100% sure if this is how it's done. -- Kind Regards, Sharaf Zaman --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-a-memory-leak-in-pgtk_draw_fringe_bitmap.patch >From 13a901f5e1d6b262ea08e05e95d3e69f99ad4e13 Mon Sep 17 00:00:00 2001 From: Sharaf Zaman Date: Sat, 23 Oct 2021 14:01:55 +0000 Subject: [PATCH] Fix a memory leak in pgtk_draw_fringe_bitmap * src/pgtkterm.c (pgtk_draw_fringe_bitmap): we had an unbalanced cairo_save/restore. --- src/pgtkterm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 86074d010d..40489c0c6b 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -3504,7 +3504,6 @@ pgtk_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct face *face = p->face; cairo_t *cr = pgtk_begin_cr_clip (f); - cairo_save (cr); /* Must clip because of partially visible lines. */ pgtk_clip_to_row (w, row, ANY_AREA, cr); @@ -3546,7 +3545,7 @@ pgtk_draw_fringe_bitmap (struct window *w, struct glyph_row *row, p->wd, p->h, p->x, p->y, p->overlay_p); } - cairo_restore (cr); + pgtk_end_cr_clip(f); } static struct atimer *hourglass_atimer = NULL; -- 2.33.0 --=-=-=--