[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about memory usage

From: Eli Zaretskii
Subject: Re: Question about memory usage
Date: Tue, 03 Apr 2018 21:22:04 +0300

> From: Michał Kondraciuk <address@hidden>
> Cc: address@hidden
> 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]