emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory leak in keyboard variables?


From: Chetan Pandya
Subject: Re: Memory leak in keyboard variables?
Date: Mon, 15 Dec 2008 18:14:20 -0800 (PST)

Although not related, spotted while looking at the code in font.c: 
font_update_drivers
       for (list = f->font_driver_list; list; list = list->next)
        if (! list->on)
-         list_table[i] = list;
+         list_table[i++] = list;
       list_table[i] = NULL;
 
Chetan


--- On Mon, 12/15/08, Chong Yidong <address@hidden> wrote:

> From: Chong Yidong <address@hidden>
> > 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 via email to

[Prev in Thread] Current Thread [Next in Thread]