Subject: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)

From: Eli Zaretskii <[email-masked]>
Date: Sun, 27 Sep 2015 11:09:18 +0300

> From: [email-masked] (K. Handa)
> Cc: [email-masked], [email-masked]
> Date: Sun, 27 Sep 2015 16:56:47 +0900
> 
> When I wrote the original code long ago, font listing and opening
> was very slow on GNU/Linux system.  So I tried to cache the result
> of listing as far as possible, and also tried to reuse the once
> opened font object as far as possible.  The latter means that even
> if a font object once created becomes unnecessary (perhaps because a
> frame is deleted), it is not freed, because, once a user displayed a
> specific character, it is displayed again with a very high
> possibility.  So, when a font is closed?  It is closed by an
> explicit call of clear-font-fache.  As far as I remember (though
> vaguely), that was my original intention.

So maybe we should simply remove (or ifdef away) the code that
compacts the font caches.  If your assumption about reusing the font
is anywhere near the truth, compacting the font cache gives us more
trouble than it gains: we get slow redisplay in some cases and random
hard-to-debug bugs, while the gains are only visible in very rare use
cases such as the one described in the Oct 2013 discussion.