all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Dima Kogan <lists@dima.secretsauce.net>
Cc: emacs-devel@gnu.org
Subject: Re: Debugging emacs memory management
Date: Wed, 11 Feb 2015 10:05:53 -0500	[thread overview]
Message-ID: <jwvegpwcx3j.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87zj8l3r32.fsf@secretsauce.net> (Dima Kogan's message of "Tue, 10 Feb 2015 22:01:36 -0800")

> 1. How does one debug this? There's a memory profiler (launched with
> (profiler-start) ),

Right, it's not really memory profiler.

Have you tried `memory-usage' (available from a GNU ELPA near you)?
It won't give you an answer, but it does give a slightly more detailed
account of the memory known to be used, so we can tell whether it's Lisp
data that's retained for too long, or whether the leak is in data not
managed in the Lisp heap, for example.

> 1.  seq 1000000 > /tmp/dat                  [ create large file on disk ]
> 2.  emacs-snapshot                          [ 32MB RSS ]

> 3.  open /tmp/dat                           [ 40MB ]
> 4.  (delete-region (point-min) (point-max)) [ 40MB ]
> 5.  (undo)                                  [ 47MB ]
> 6.  (kill-buffer)                           [ 40MB ]
> 7.  (garbage-collect)                       [ 40MB ]

> 3a. open /tmp/dat                           [ 46MB ]
> 4a. (delete-region (point-min) (point-max)) [ 60MB ]
> 5a. (undo)                                  [ 60MB ]
> 6a. (kill-buffer)                           [ 60MB ]
> 7a. (garbage-collect)                       [ 60MB ]

> 3b. open /tmp/dat                           [ 60MB ]
> 4b. (delete-region (point-min) (point-max)) [ 60MB ]
> 5b. (undo)                                  [ 60MB ]
> 6b. (kill-buffer)                           [ 60MB ]
> 7b. (garbage-collect)                       [ 60MB ]

Failure to shrink after you stop using something is not considered
a leak: there can be any number of reasons why some part of Emacs
decides not to return the space to the OS, even though it's known (at
some level) to be free and can/will be reused for something else in
the future.

> Without knowing the internals, it looks like a leak, but I can't be
> sure.  If I move around the /tmp/dat buffer, and (delete-region) various
> other chunks, I can eat up even more memory.

That's no guarantee that there's a leak, but if you can keep eating
arbitrary amount of memory by repeated use of
delete-region+kill-buffer+find-file then it does look like
a leak, indeed.


        Stefan



  reply	other threads:[~2015-02-11 15:05 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-11  6:01 Debugging emacs memory management Dima Kogan
2015-02-11 15:05 ` Stefan Monnier [this message]
2015-02-15 20:28   ` Dima Kogan
2015-02-15 20:47     ` Eli Zaretskii
2015-02-16  1:39       ` Stefan Monnier
2015-02-17  7:59         ` Dima Kogan
2015-02-17 15:59           ` Eli Zaretskii
2015-02-18  0:07           ` Stefan Monnier
2015-02-11 19:07 ` Florian Weimer
2015-09-15 19:27 ` Dima Kogan
2015-09-16 16:28   ` Paul Eggert
2015-09-20 22:01     ` Dima Kogan
2015-09-21  6:46       ` Eli Zaretskii
2015-09-21  8:54         ` Dima Kogan
2015-09-21 10:00           ` Eli Zaretskii
2015-09-21 10:21             ` Eli Zaretskii
2015-09-22 21:33               ` Dima Kogan
2015-09-23  6:35                 ` Eli Zaretskii
2015-09-23  6:37                   ` Dima Kogan
2015-09-23  7:16                     ` Eli Zaretskii
2015-10-05  7:21               ` Dima Kogan
2015-10-05  7:55                 ` Eli Zaretskii
2015-10-05  8:24                   ` Dima Kogan
2015-10-05  8:33                     ` Eli Zaretskii
2015-10-05  8:43                     ` Eli Zaretskii
2015-10-05  9:24                       ` Dima Kogan
2015-10-05  9:49                         ` Dima Kogan
2015-10-05  9:58                           ` Andreas Schwab
2015-10-05 10:02                             ` Dima Kogan
2015-10-05 10:47                               ` Eli Zaretskii
2015-10-05 18:19                                 ` Dima Kogan
2015-10-05 18:24                                   ` Eli Zaretskii
2015-10-05 23:21                                   ` Dima Kogan
2015-10-06  2:41                                     ` Eli Zaretskii
2015-10-08 21:51                                       ` Dima Kogan
2015-09-16 16:34   ` Davis Herring
2015-09-16 22:03   ` Markus Triska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvegpwcx3j.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=lists@dima.secretsauce.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.