From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Memory leaks in font objects Date: Thu, 24 Oct 2013 20:41:31 -0400 Message-ID: References: <5268BEDB.1090705@yandex.ru> <52694180.2070708@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1382661715 8990 80.91.229.3 (25 Oct 2013 00:41:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Oct 2013 00:41:55 +0000 (UTC) Cc: Emacs development discussions To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 25 02:41:58 2013 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 1VZVTS-0000xS-EN for ged-emacs-devel@m.gmane.org; Fri, 25 Oct 2013 02:41:58 +0200 Original-Received: from localhost ([::1]:56815 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZVTR-0005AY-Vo for ged-emacs-devel@m.gmane.org; Thu, 24 Oct 2013 20:41:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZVTH-0005AH-Pc for emacs-devel@gnu.org; Thu, 24 Oct 2013 20:41:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZVTA-0006Ti-CL for emacs-devel@gnu.org; Thu, 24 Oct 2013 20:41:47 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:11248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZVTA-0006TY-8O for emacs-devel@gnu.org; Thu, 24 Oct 2013 20:41:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFxIYv/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJCyHcgbBLZEKA6R6gV6DEw X-IPAS-Result: Av4EABK/CFFFxIYv/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJCyHcgbBLZEKA6R6gV6DEw X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="36298637" Original-Received: from 69-196-134-47.dsl.teksavvy.com (HELO ceviche.home) ([69.196.134.47]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 24 Oct 2013 20:41:36 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 664B2660A2; Thu, 24 Oct 2013 20:41:31 -0400 (EDT) In-Reply-To: <52694180.2070708@yandex.ru> (Dmitry Antipov's message of "Thu, 24 Oct 2013 19:49:20 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 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:164521 Archived-At: >> Oddly enough, I'm not sure it's a leak. Here's the result of my test: >> >> VM RSS >> initial 204 24 >> after 1 522 290 >> after 2 539 305 >> after 3 542 308 >> after 4 542 308 >> >> So it's more like "once malloced, the memory can be reused by Emacs, but >> not by another process because we never return it to the OS". > IIUC no :-(. I tried the following: You misunderstood: I did not say that those megabytes are available to malloc. I just pointed out that it's a similar phenomenon to the one that takes place with malloc. > But, if you need to allocate something else, you will need > more memory. But the objects are still usable: there is still a pointer to them somewhere and some sequence of events can bring Emacs to a state where those objects are used again. So it is not strictly speaking a leak, in my book. Also, I'm curious how you bumped into this problem. Was it by looking at the code, or was it in "real life use", or in some test you happened to be running? The fact that the wasted memory doesn't grow indefinitely, and only grows with the fonts actually used, makes me think that it shouldn't be a problem in real life usage. >> What the difference between "close" and "finalize"? > Nothing except "close" is a part of existing interface which I don't want > to change (at this moment at least), and requires extra frame argument. So it'd be better to merge the two. Stefan