From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Antipov Newsgroups: gmane.emacs.devel Subject: Re: Memory leaks in font objects Date: Thu, 24 Oct 2013 19:49:20 +0400 Message-ID: <52694180.2070708@yandex.ru> References: <5268BEDB.1090705@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1382629899 2593 80.91.229.3 (24 Oct 2013 15:51:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Oct 2013 15:51:39 +0000 (UTC) Cc: Emacs development discussions To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 24 17:51:43 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 1VZNCI-0002S7-VR for ged-emacs-devel@m.gmane.org; Thu, 24 Oct 2013 17:51:43 +0200 Original-Received: from localhost ([::1]:54928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZNCI-0001Wc-Kk for ged-emacs-devel@m.gmane.org; Thu, 24 Oct 2013 11:51:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZNC9-0001WK-2N for emacs-devel@gnu.org; Thu, 24 Oct 2013 11:51:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZNC2-0003Lf-0M for emacs-devel@gnu.org; Thu, 24 Oct 2013 11:51:33 -0400 Original-Received: from forward2h.mail.yandex.net ([84.201.187.147]:58760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZNC1-0003LU-Lm for emacs-devel@gnu.org; Thu, 24 Oct 2013 11:51:25 -0400 Original-Received: from smtp4h.mail.yandex.net (smtp4h.mail.yandex.net [84.201.186.21]) by forward2h.mail.yandex.net (Yandex) with ESMTP id 5E2BD70368D; Thu, 24 Oct 2013 19:49:21 +0400 (MSK) Original-Received: from smtp4h.mail.yandex.net (localhost [127.0.0.1]) by smtp4h.mail.yandex.net (Yandex) with ESMTP id 0983C2C1789; Thu, 24 Oct 2013 19:49:20 +0400 (MSK) Original-Received: from unknown (unknown [37.139.80.10]) by smtp4h.mail.yandex.net (nwsmtp/Yandex) with ESMTP id XHsICAdmgV-nKMK1daw; Thu, 24 Oct 2013 19:49:20 +0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1382629760; bh=gi7m/V99eBIoMr4TkqWophhgjSvlMQTpV9I9BurIvDg=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=X3ekjW4WaiIYnzId8RNA9shUPSPZoBZETZzDtHlOqIw9LVXdskzPqwmnWSXRerQcJ 9MpsqOUMWKo7cMRVyuKwvwEV7gq6iJkt9t5XM2HZkNIUTTSt3MNuKF7zGR4Jj+UykH lAjTkXTDgy8RWGprBNG0crqWNvd/DFafvaybZSNg= Authentication-Results: smtp4h.mail.yandex.net; dkim=pass header.i=@yandex.ru User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 84.201.187.147 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:164515 Archived-At: On 10/24/2013 06:19 PM, Stefan Monnier wrote: > 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: initial: 32M RSS then M-x bloat-font, M-x set-frame-font "fixed", M-x garbage-collect: 372M then M-x byte-force-recompile [all lisp/ subdir], M-x garbage-collect: 437M If 372M is (mostly) free but just too fragmented to release, byte-force-recompile should reuse a lot of memory - so why +65M? But, 2nd run of bloat-font do not add too much. Why? Consider XLoadQueryFont example. When you do not call XFreeFont but just lost XFontStruct pointer, the font is still allocated by Xlib. Since you lost the pointer, you can't use this font unless you call XLoadQueryFont for the same font again and got the pointer to previously allocated resource (assuming that you do not lost the connection to X display). So 2nd, 3rd, etc. calls to bloat-font will just re-use font resources you lost before. But, if you need to allocate something else, you will need more memory. > 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. Dmitry