unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#51354: [PATCH] Fix a memory leak in pgtk_draw_fringe_bitmap
@ 2021-10-23 14:34 Sharaf Zaman
       [not found] ` <87zgqzda7w.fsf@sdf.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Sharaf Zaman @ 2021-10-23 14:34 UTC (permalink / raw)
  To: 51354

[-- 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#51355: Fwd: [PATCH] Fix a memory leak in pgtk_draw_fringe_bitmap
       [not found] ` <87zgqzda7w.fsf@sdf.org>
@ 2021-10-23 15:41   ` Sharaf Zaman
  2021-10-24 18:09     ` bug#51354: " Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Sharaf Zaman @ 2021-10-23 15:41 UTC (permalink / raw)
  To: 51355

[-- Attachment #1: Type: text/plain, Size: 415 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 over an email, 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#51354: [PATCH] Fix a memory leak in pgtk_draw_fringe_bitmap
  2021-10-23 15:41   ` bug#51355: Fwd: " Sharaf Zaman
@ 2021-10-24 18:09     ` Lars Ingebrigtsen
       [not found]       ` <874k95txyd.fsf@sdf.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-10-24 18:09 UTC (permalink / raw)
  To: Sharaf Zaman; +Cc: 51355, 51354, Yuuki Harano

Sharaf Zaman <shzam@sdf.org> writes:

> 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).

Makes sense to me, so I've applied it to the pgtk branch, but perhaps
Yuuki has a comment (added to the CCs).

> PS: This is my first time sending a patch over an email, I'm not 100%
> sure if this is how it's done.

Looked perfect.  :-)

This change was small enough to apply without assigning copyright to the
FSF, but for future patches you want to submit, it might make sense to
get the paperwork started now, so that subsequent patches can be applied
speedily. Would you be willing to sign such paperwork?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#51355: bug#51354: [PATCH] Fix a memory leak in pgtk_draw_fringe_bitmap
       [not found]       ` <874k95txyd.fsf@sdf.org>
@ 2021-10-25 13:35         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-10-25 13:35 UTC (permalink / raw)
  To: Sharaf Zaman; +Cc: 51355, 51354

Sharaf Zaman <shzam@sdf.org> writes:

>> This change was small enough to apply without assigning copyright to the
>> FSF, but for future patches you want to submit, it might make sense to
>> get the paperwork started now, so that subsequent patches can be applied
>> speedily. Would you be willing to sign such paperwork?
>
> Sure! Where can I do that?

Great!  Here's the form to get started:


Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.

Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES

[What is the name of the program or package you're contributing to?]
Emacs

[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]

[Do you have an employer who might have a basis to claim to own
your changes?  Do you attend a school which might make such a claim?]

[For the copyright registration, what country are you a citizen of?]

[What year were you born?]

[Please write your email address here.]

[Please write your postal address here.]

[Which files have you changed so far, and which new files have you written
so far?]





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-25 13:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-23 14:34 bug#51354: [PATCH] Fix a memory leak in pgtk_draw_fringe_bitmap Sharaf Zaman
     [not found] ` <87zgqzda7w.fsf@sdf.org>
2021-10-23 15:41   ` bug#51355: Fwd: " 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

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).