|
From: Ethan M. <merritt@u.washington.edu> - 2004-10-03 22:18:11
|
On Sunday 03 October 2004 11:49 am, Ethan Merritt wrote:
> On Saturday 02 October 2004 05:43 pm, Daniel J Sebald wrote:
> > It is the QF causing problems which is executed as:
> > case 'F':
> > /* Strip out just the font name */
> > c = &(buffer[strlen(buffer)-1]);
> > while (*c <= ' ') *c-- = '\0';
> > pr_font(&buffer[2]);
> > XSetFont(dpy,gc,font->fid);
> > break;
> >
> > When I comment out the "XSetFont" function, the memory leak goes away.
OK. I confirm the leak, although I don't see any processes other than
gnuplot_x11 itself being affected.
I thought I knew how x11 fonts worked, but clearly I don't.
Three observations. I can't really explain any of them, but I'd be interested
whether you see the same:
1) The biggie.
X11 font handling has broken badly sometime since I first wrote it.
I'm not at all sure when, and I don't know how much it has to do with
the problem you have identified. It seems broken in the V4.0.0
release version also. The upshot is that if you open new plot windows
with new fonts, then old windows do not keep their original fonts.
I can't figure out exactly whose font they get instead, but there
must be a bookkeeping error somewhere.
2) the above call to XSetFont() returns BadResource, which is strange
because clearly the call is actually working. Also strange because
that's not listed on the man page as a possible return code.
3) adding the following to the head of pr_font() seems to make the
leak go away for a single-window test case.
But what if another plot is using this font?????
On the other hand, see problem (1); this is already messed up.
--- gplt_x11.c.orig
+++ gplt_x11.c
@@ -5078,6 +5085,11 @@
if (!fontname)
fontname = FallbackFont;
+
+ /* EAM DEBUG!!!! Release current font, if any */
+ if (font)
+ XFreeFont(dpy, font);
+
|