all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Dima Kogan <dima@secretsauce.net>
Cc: 21509@debbugs.gnu.org
Subject: bug#21509: 25.0.50; X11 error: BadPixmap when creating first emacsclient frame; and memory leak
Date: Tue, 05 Sep 2017 10:18:25 +0200	[thread overview]
Message-ID: <59AE5DD1.9050602@gmx.at> (raw)
In-Reply-To: <87wp5d8y37.fsf@scrawny>

 > So in the case of lucid widgets, you not only fixed the bug,

I coin it a "fix" because I just pushed the same workaround that had
been used for the GTK build before.  But it hardly qualifies as a real
fix because it makes the referencing counting mechanism practically
obsolete for any kind of frame deletion.

 > but also
 > massively plugged the memory leaks that were associated with new emacs
 > frames. Awesome!

IIUC your numbers of Lucid with scrollbars now coincide with the numbers
of Lucid without scrollbars before the "fix".  OTOH the numbers for GTK
largely coincide with those of Lucid with scrollbars before the "fix".
So X itself seems much more dominant than any toolkit particularities.

 > The fix doesn't affect GTK, so that plot is just for reference. It's
 > clearly still leaking, and its baseline memory usage is higher. I was
 > thinking that GTK does a larger number of small allocations that are
 > soon freed, and thus suffers from more fragmentation issues. To test
 > that, I invoked malloc_trim(0) just after t=450 in the gtk run. This
 > asks malloc to return the the kernel all the unused memory it's holding.
 > And we see a 5MB drop. So the GTK leaks aren't as bad as they look.

I think what was going on before the "fix" is this: We free data we
shouldn't, probably due to a bug in the reference counting mechanism.
Some time later, after that data got overwritten, the new data triggers
the error in the toolkit code.  I say "some time later" because the
error (1) apparently nowhere triggers with _every_ invocation of
emacsclient, (2) its frequency seems to differ according to the various
bug reports from every third invocation to every fifth, and (3) it seems
to have a fairly constant frequency, at least here when it starts to
happen every third invocation it will continue to happen every third
invocation.

While the above tries to explain the bug reported by the toolkit, any
memory leak should follow from trying to delete the terminal but when
doing so we forget to explicitly free some (maybe font related) data and
when invoking a new client we reallocate that data instead of reusing
the one we forgot about.

This does not explain any difference between the GTK (before the "fix")
and Lucid (after the "fix") behaviors.  What happens with GTK when you
allow it to delete the terminal by allowing terminal->reference_count
drop to zero?  If it does not crash immediately, is the memory leak more
heavy than it is now?

Also, could you try whether changing ‘gc-cons-threshold’ in either
direction has any impact on the occurrence of the toolkit bug or the
growth of the memory leak?  Once I thought that this could affect the
frequency of the error but didn't get any conclusive results.

Thanks, martin






  reply	other threads:[~2017-09-05  8:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-18  4:41 bug#21509: 25.0.50; X11 error: BadPixmap when creating first emacsclient frame; and memory leak Dima Kogan
     [not found] ` <handler.21509.B.14425512741008.ack@debbugs.gnu.org>
2015-10-02  7:32   ` bug#21509: update Dima Kogan
2017-09-03 10:15 ` bug#21509: 25.0.50; X11 error: BadPixmap when creating first emacsclient frame; and memory leak martin rudalics
2017-09-05  6:21   ` Dima Kogan
2017-09-05  8:18     ` martin rudalics [this message]
2017-09-09  1:49       ` Dima Kogan
2017-09-09  7:59         ` martin rudalics
2017-10-15  3:48           ` Dima Kogan
2017-10-15  9:40             ` martin rudalics
2017-10-15 18:24               ` Dima Kogan
2017-10-16  7:42                 ` martin rudalics
2017-10-16 16:33                   ` Dima Kogan
2017-10-17  8:58                     ` martin rudalics

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

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

  git send-email \
    --in-reply-to=59AE5DD1.9050602@gmx.at \
    --to=rudalics@gmx.at \
    --cc=21509@debbugs.gnu.org \
    --cc=dima@secretsauce.net \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.