From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Initial frame faces Date: Mon, 27 Jan 2014 18:03:40 +0200 Message-ID: <83ha8p9ztv.fsf@gnu.org> References: <52E201ED.1080108@yandex.ru> <83iot9eryn.fsf@gnu.org> <52E22697.9000901@yandex.ru> <83d2jheoh4.fsf@gnu.org> <52E62C34.1020209@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1390838641 24440 80.91.229.3 (27 Jan 2014 16:04:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Jan 2014 16:04:01 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 27 17:04:08 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W7ofO-0000Rh-Rg for ged-emacs-devel@m.gmane.org; Mon, 27 Jan 2014 17:04:06 +0100 Original-Received: from localhost ([::1]:60331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7ofO-0007mR-FV for ged-emacs-devel@m.gmane.org; Mon, 27 Jan 2014 11:04:06 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7ofF-0007d1-0a for emacs-devel@gnu.org; Mon, 27 Jan 2014 11:04:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W7of9-0000w4-NZ for emacs-devel@gnu.org; Mon, 27 Jan 2014 11:03:56 -0500 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:33265) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7of9-0000vj-G0 for emacs-devel@gnu.org; Mon, 27 Jan 2014 11:03:51 -0500 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0N0200300HQ14300@a-mtaout20.012.net.il> for emacs-devel@gnu.org; Mon, 27 Jan 2014 18:03:49 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N02003V1HYB5400@a-mtaout20.012.net.il>; Mon, 27 Jan 2014 18:03:47 +0200 (IST) In-reply-to: <52E62C34.1020209@yandex.ru> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.166 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:169167 Archived-At: > Date: Mon, 27 Jan 2014 13:51:48 +0400 > From: Dmitry Antipov > CC: emacs-devel@gnu.org > > On 01/24/2014 01:08 PM, Eli Zaretskii wrote: > > > But perhaps we should step back a notch and discuss the original > > problem. What problem(s) did you want to solve, exactly? > > The problem is that free_frame_faces is never called when an initial > frame is deleted. With valgrind, this is reported as memory leak: > > ==19033== 12,088 (40 direct, 12,048 indirect) bytes in 1 blocks are definitely lost in loss record 11,087 of 11,232 > ==19033== at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) > ==19033== by 0x5E1179: xmalloc (alloc.c:677) > ==19033== by 0x51B43A: make_face_cache (xfaces.c:4202) > ==19033== by 0x512D36: init_frame_faces (xfaces.c:666) > ==19033== by 0x428442: make_initial_frame (frame.c:576) > ==19033== by 0x4BA3ED: init_window_once (window.c:7096) > ==19033== by 0x565B01: main (emacs.c:1201) > > IIUC this may be fixed in three ways: > > 1) If an initial frame is never used to display anything, > we don't need faces on that frame at all. > > 2) initial_terminal should have a hook to free faces on an initial frame. > > 3) If each frame always has a face cache, it's reasonable to call > free_frame_faces in delete_frame and not in frame type-specific hooks. I think 2) is the best, because it leaves the possibility of having a different delete_frame_hook for each terminal type (although they seem to be identical for now). free_frame_faces already defends itself against a NULL cache (actually, it over-defends itself, as all of its subroutines check that as well), so it should be safe to call it from initial_terminal's hook, even if the face cache is not initialized in some situation.