From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chetan Pandya Newsgroups: gmane.emacs.devel Subject: Re: Memory leak in keyboard variables? Date: Mon, 15 Dec 2008 18:14:20 -0800 (PST) Message-ID: <964372.27721.qm@web83201.mail.mud.yahoo.com> Reply-To: pandyacus@sbcglobal.net NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1229393684 20942 80.91.229.12 (16 Dec 2008 02:14:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Dec 2008 02:14:44 +0000 (UTC) Cc: emacs-devel@gnu.org To: Chong Yidong , Kenichi Handa Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 16 03:15:48 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LCPTP-0001pw-H6 for ged-emacs-devel@m.gmane.org; Tue, 16 Dec 2008 03:15:48 +0100 Original-Received: from localhost ([127.0.0.1]:53319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LCPSD-0000yD-2N for ged-emacs-devel@m.gmane.org; Mon, 15 Dec 2008 21:14:33 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LCPS7-0000xt-Q9 for emacs-devel@gnu.org; Mon, 15 Dec 2008 21:14:27 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LCPS3-0000ve-KV for emacs-devel@gnu.org; Mon, 15 Dec 2008 21:14:26 -0500 Original-Received: from [199.232.76.173] (port=40529 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LCPS3-0000vY-Dp for emacs-devel@gnu.org; Mon, 15 Dec 2008 21:14:23 -0500 Original-Received: from web83201.mail.mud.yahoo.com ([216.252.101.45]:37519) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1LCPS3-0005Pg-1K for emacs-devel@gnu.org; Mon, 15 Dec 2008 21:14:23 -0500 Original-Received: (qmail 28724 invoked by uid 60001); 16 Dec 2008 02:14:21 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=sbcglobal.net; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:Cc:MIME-Version:Content-Type:Message-ID; b=1Iwa+3eehhpEHN10d62YZ7qIX5XlOT6eVOyEcDdl0PM50GV0YH+vya0JmUrBz1C4Z5m0jHfbiBvPkM+p2+8j839R441kKfxqdWGLBPfjNuovDiBqZU/ZY3HaX+Ntw0uaIKSfJxoRDGtj/4xCqQZiUb+X3GmP041vfgKXA3ptQZ8=; X-YMail-OSG: rOnBf04VM1nG642ezBPViyw.bTTivKRESwpuABn7VPN0_kOYmDlgH8yCT6SApJY2xiXPK6aRo0hL5OQXLcst7CY6JWS9Itp9BwCOICZ4gatK3c0QrvgYw0cU0jKAsq32H7SkfhqZkXpKN0LlcmWpddzpoXcdkZoR3tz8_HKilaYfKXWTIyAQV2GRgr69DHX.AE.kmbdDqBedsn28vBcFJRK93ligK22U1G1IkJ60 Original-Received: from [76.200.182.195] by web83201.mail.mud.yahoo.com via HTTP; Mon, 15 Dec 2008 18:14:20 PST X-Mailer: YahooMailWebService/0.7.218.2 X-detected-operating-system: by monty-python.gnu.org: FreeBSD 6.x (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:106949 Archived-At: 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 wrote: > From: Chong Yidong > > 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);