all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Question about memory usage
Date: Tue, 03 Apr 2018 21:22:04 +0300	[thread overview]
Message-ID: <83po3g40c3.fsf@gnu.org> (raw)
In-Reply-To: <690641bc-fc49-922a-26bd-6f92322d0cc0@zoho.com> (message from Michał Kondraciuk on Tue, 3 Apr 2018 19:57:34 +0200)

> From: Michał Kondraciuk <k.michal@zoho.com>
> Cc: help-gnu-emacs@gnu.org
> Date: Tue, 3 Apr 2018 19:57:34 +0200
> 
> > To answer your question: yes, I think this is expected, given that you
> > set buffer-undo-list to nil (what is the purpose of that, btw?). 
> 
> No purpose, but some external packages display information in a way 
> similar to this sexp, where undo information is also recorded (needlessly):

To disable undo, you should bind buffer-undo-list to t, not to nil.
And with-temp-buffer already does that, because temporary buffers have
their undo disabled by default.

> Obviously normally this isn't a problem because you won't run this code 
> in a loop, but if you leave Emacs open for a long time and run this sexp 
> as part of some command many times, memory can accumulate (I think, it's 
> why I asked if Emacs will finally free this unused memory).

In normal usage, the memory footprint of an Emacs session levels out
after some time, and stays approximately fixed, unless you do
something extraordinary.

> > When Emacs ends up requesting more memory from the OS, it usually
> > doesn't release that memory when it is no longer needed, but keeps it
> > in the process's address space and reuses it if/when it needs more
> > memory.
> But shouldn't Emacs reuse the memory from previous loop iteration 
> instead of allocating it?

That depends on the heap fragmentation and the efficiency of the
memory allocating functions to deal with fragmentation.

> Also, if the sexp is modified like this, Emacs 
> memory usage is at the same level:
> 
> 
> (while t
>    (with-temp-buffer
>      (insert "a")
>      (setq buffer-undo-list (list (cons (point-min) (point-max))))))

Did you try not setting buffer-undo-list at all?  What did you see
then?



  reply	other threads:[~2018-04-03 18:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-02 11:57 Question about memory usage Michał Kondraciuk
2018-04-03  2:16 ` Óscar Fuentes
2018-04-03  6:28 ` Eli Zaretskii
2018-04-03 12:28   ` Stefan Monnier
2018-04-03 12:40     ` Eli Zaretskii
2018-04-03 12:51       ` Eli Zaretskii
2018-04-03 13:13       ` Stefan Monnier
2018-04-03 14:03         ` Eli Zaretskii
2018-04-03 14:27           ` Stefan Monnier
2018-04-03 15:16             ` Eli Zaretskii
2018-04-03 21:14               ` Stefan Monnier
2018-04-03 17:57   ` Michał Kondraciuk
2018-04-03 18:22     ` Eli Zaretskii [this message]
2018-04-03 19:16       ` Michał Kondraciuk
2018-04-04  6:55         ` Eli Zaretskii
2018-04-05 18:06           ` Michał Kondraciuk
2018-04-05 18:40             ` Eli Zaretskii
2018-04-05 18:54             ` Stefan Monnier
2018-04-07 13:15               ` Michał Kondraciuk
2018-04-07 13:26                 ` Eli Zaretskii
2018-04-07 15:22                   ` Stefan Monnier
2018-04-07 18:39                     ` Michał Kondraciuk
2018-04-03 21:18       ` Stefan Monnier
2018-04-04  6:08         ` Eli Zaretskii
2018-04-04 21:45           ` Stefan Monnier

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=83po3g40c3.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /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.