From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Ami Fischman" Newsgroups: gmane.emacs.devel Subject: Re: how do you track down emacs memory leaks? Date: Sat, 20 Dec 2008 08:27:49 -0800 Message-ID: <9aa0cfde0812200827u44c9d436tbacbb47d9e07901f@mail.gmail.com> References: <9aa0cfde0811012105o20c51089j1cd80d81d2895a6d@mail.gmail.com> <87d4hclu5q.fsf@cyd.mit.edu> <9aa0cfde0811030724s2ee667e2l59cc94a97e4fc1f@mail.gmail.com> <87k5bjfmvz.fsf@cyd.mit.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1229790502 10473 80.91.229.12 (20 Dec 2008 16:28:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Dec 2008 16:28:22 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Chong Yidong" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 20 17:29:28 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 1LE4hW-0002p3-PS for ged-emacs-devel@m.gmane.org; Sat, 20 Dec 2008 17:29:15 +0100 Original-Received: from localhost ([127.0.0.1]:47851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LE4gK-0003nS-ES for ged-emacs-devel@m.gmane.org; Sat, 20 Dec 2008 11:28:00 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LE4gE-0003nN-KM for emacs-devel@gnu.org; Sat, 20 Dec 2008 11:27:54 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LE4gC-0003nB-W9 for emacs-devel@gnu.org; Sat, 20 Dec 2008 11:27:53 -0500 Original-Received: from [199.232.76.173] (port=53682 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LE4gC-0003n8-Pp for emacs-devel@gnu.org; Sat, 20 Dec 2008 11:27:52 -0500 Original-Received: from mail-ew0-f13.google.com ([209.85.219.13]:65280) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LE4gC-0001rN-Bf for emacs-devel@gnu.org; Sat, 20 Dec 2008 11:27:52 -0500 Original-Received: by ewy6 with SMTP id 6so1628151ewy.18 for ; Sat, 20 Dec 2008 08:27:50 -0800 (PST) Original-Received: by 10.210.88.7 with SMTP id l7mr5123726ebb.114.1229790470213; Sat, 20 Dec 2008 08:27:50 -0800 (PST) Original-Received: by 10.210.92.12 with HTTP; Sat, 20 Dec 2008 08:27:49 -0800 (PST) In-Reply-To: <87k5bjfmvz.fsf@cyd.mit.edu> Content-Disposition: inline X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:107126 Archived-At: This leak ended up being caused by the bug I reported last night (mode-line-eol-desc-cache being grown indefinitely). Gnus was not the cause but rather the trigger, since it visits so many files (using nnml backend) and visiting files was a prime way to tickle the mode-line-eol-desc-cache bug. Since this thread was about debugging methods, I figured I'd add to it the way that I finally found the culprit: (defun ami-big-var-p (sym) (when (and (boundp sym) (> (length (prin1-to-string (symbol-value sym))) (* 1024 1024))) t)) (mapatoms '(lambda (sym) (when (ami-big-var-p sym) (message (symbol-name sym))))) This led me to the insanely large variable and from there it was just a matter of tracking down its construction. Cheers, -a On Tue, Nov 4, 2008 at 8:59 AM, Chong Yidong wrote: > "Ami Fischman" writes: > >>> Does this problem only show up when you use gnus? >> >> Yes. >> >>> Could you try keeping >>> another Emacs session around for other non-gnus usage, and see if it >>> leaks memory? >> >> I have and it doesn't. At least not nearly at the rate that the >> gnus-using session does. >> >> I updated my version of gnus from ngnus-0.10 to CVS head yesterday and >> the leak seems to have slowed down significantly - only about 8MB >> overnight. So I suspect some trigger has been coincidentally >> suppressed, but it seems that no elisp code should be able to cause >> emacs to grow in memory usage disproportional to the numbers reported >> by memory-usage, so there is still probably a lurking leak in emacs. >> >> Do you have any tools/techniques you use to track down C-level leaks? > > I'm afraid not. Maybe someone else on this list can suggest something. > > One possibility is to try and write a simple test case that demonstrates > the leak. For instance, a short Elisp program that keeps creating and > killing network processes. If such a program causes memory to increase, > that would demonstrate that the memory leak is occurring in the Emacs > network process code. >