all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: Kenichi Handa <handa@m17n.org>
Cc: emacs-devel@gnu.org
Subject: Re: Memory leak in keyboard variables?
Date: Sun, 14 Dec 2008 22:16:05 -0500	[thread overview]
Message-ID: <87oczeuo0a.fsf@cyd.mit.edu> (raw)
In-Reply-To: <E1LC2Dl-0001R1-VC@etlken.m17n.org> (Kenichi Handa's message of "Mon, 15 Dec 2008 10:26:05 +0900")

Kenichi Handa <handa@m17n.org> writes:

> The strategy is to record all font-objects in font-entities, and
> record all font-entities in a cache of each font-backend.  The caches
> are freed when `delete-frame' calls font_update_drivers with
> new_drivers as nil

Thanks for the explanation.  It was very helpful.

I think the problem is that font_clear_cache is incorrectly written.
For some reason, it assumes that the font cache entries have the form

  (font-spec [entity1 entity2...])

when in fact, they have the form

  (font-spec entity1 entity2...)

The following patch to font_clear_cache frees 60-70k of memory per
terminal.

Do you know why font_clear_cache was written this way, and whether there
could be any other places in the font code that make this incorrect
assumption?

*** trunk/src/font.c.~1.99.~	2008-12-13 10:39:30.000000000 -0500
--- trunk/src/font.c	2008-12-14 22:06:26.000000000 -0500
***************
*** 2651,2671 ****
       struct font_driver *driver;
  {
    Lisp_Object tail, elt;
  
    /* CACHE = (DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...) */
    for (tail = XCDR (XCDR (cache)); CONSP (tail); tail = XCDR (tail))
      {
        elt = XCAR (tail);
!       if (CONSP (elt) && FONT_SPEC_P (XCAR (elt)) && VECTORP (XCDR (elt)))
  	{
! 	  Lisp_Object vec = XCDR (elt);
! 	  int i;
! 
! 	  for (i = 0; i < ASIZE (vec); i++)
  	    {
! 	      Lisp_Object entity = AREF (vec, i);
  
! 	      if (EQ (driver->type, AREF (entity, FONT_TYPE_INDEX)))
  		{
  		  Lisp_Object objlist = AREF (entity, FONT_OBJLIST_INDEX);
  
--- 2651,2671 ----
       struct font_driver *driver;
  {
    Lisp_Object tail, elt;
+   Lisp_Object tail2, entity;
  
    /* CACHE = (DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...) */
    for (tail = XCDR (XCDR (cache)); CONSP (tail); tail = XCDR (tail))
      {
        elt = XCAR (tail);
!       /* elt should have the form (FONT-SPEC FONT-ENTITY ...) */
!       if (CONSP (elt) && FONT_SPEC_P (XCAR (elt)))
  	{
! 	  for (tail2 = XCDR (elt); CONSP (tail2); tail2 = XCDR (tail2))
  	    {
! 	      entity = XCAR (tail2);
  
! 	      if (FONT_ENTITY_P (entity)
! 		  && EQ (driver->type, AREF (entity, FONT_TYPE_INDEX)))
  		{
  		  Lisp_Object objlist = AREF (entity, FONT_OBJLIST_INDEX);
  




  reply	other threads:[~2008-12-15  3:16 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-15  1:26 Memory leak in keyboard variables? Kenichi Handa
2008-12-15  3:16 ` Chong Yidong [this message]
2008-12-15  4:06   ` image cache (was: Memory leak in keyboard variables?) Stefan Monnier
2008-12-15  4:12     ` Eli Zaretskii
2008-12-15 15:19       ` image cache Stefan Monnier
2008-12-15 16:08         ` Chong Yidong
2008-12-15 20:09           ` Stefan Monnier
2008-12-16  1:41           ` Miles Bader
2008-12-16  4:56             ` Chetan Pandya
2008-12-16  7:02               ` Chetan Pandya
2008-12-16  4:31   ` Memory leak in keyboard variables? Kenichi Handa
  -- strict thread matches above, loose matches on Subject: below --
2008-12-16  2:14 Chetan Pandya
2008-12-16  3:33 ` Chong Yidong
2008-12-11  3:03 Chong Yidong
2008-12-11  9:30 ` Andreas Schwab
2008-12-11 15:09   ` Chong Yidong
2008-12-11 20:43     ` Chong Yidong
2008-12-13 14:19       ` Markus Triska
2008-12-13 19:09         ` Chong Yidong
2008-12-16 14:11         ` Chong Yidong
2008-12-17  4:40           ` Stephen J. Turnbull
2008-12-20  1:50             ` Chong Yidong
2008-12-20 15:34               ` Jan Djärv
2008-12-20 17:09                 ` Markus Triska
2008-12-20 17:45                 ` Dan Nicolaescu
2008-12-20 18:37                   ` Dan Nicolaescu
2008-12-20 20:41                 ` Chong Yidong
2008-12-11 15:59 ` Stefan Monnier

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=87oczeuo0a.fsf@cyd.mit.edu \
    --to=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=handa@m17n.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 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.