unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Sharaf Zaman <shzam@sdf.org>
To: 51354@debbugs.gnu.org
Subject: bug#51354: [PATCH] Fix a memory leak in pgtk_draw_fringe_bitmap
Date: Sat, 23 Oct 2021 14:34:48 +0000	[thread overview]
Message-ID: <87pmrvbyif.fsf@sdf.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 402 bytes --]


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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-a-memory-leak-in-pgtk_draw_fringe_bitmap.patch --]
[-- Type: text/x-patch, Size: 1032 bytes --]

From 13a901f5e1d6b262ea08e05e95d3e69f99ad4e13 Mon Sep 17 00:00:00 2001
From: Sharaf Zaman <shzam@sdf.org>
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


             reply	other threads:[~2021-10-23 14:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-23 14:34 Sharaf Zaman [this message]
     [not found] ` <87zgqzda7w.fsf@sdf.org>
2021-10-23 15:41   ` bug#51355: Fwd: [PATCH] Fix a memory leak in pgtk_draw_fringe_bitmap Sharaf Zaman
2021-10-24 18:09     ` bug#51354: " Lars Ingebrigtsen
     [not found]       ` <874k95txyd.fsf@sdf.org>
2021-10-25 13:35         ` bug#51355: " Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmrvbyif.fsf@sdf.org \
    --to=shzam@sdf.org \
    --cc=51354@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).