GNU bug report logs -
#45200
Wishlist: There should be a `malloc-trim' function
Previous Next
Reported by: Konstantin Kharlamov <hi-angel <at> yandex.ru>
Date: Sat, 12 Dec 2020 18:44:02 UTC
Severity: wishlist
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #32 received at 45200 <at> debbugs.gnu.org (full text, mbox):
> # Steps to reproduce:
>
> 1. Run `mkdir /tmp/.emacs.d`
> 2. Run emacs as `HOME=/tmp/ emacs`, and measure its PSS
> 3. Create a file /tmp/.emacs.d/early-init.el with content:
>
> ;; only run garbage collection on idle
> (setq gc-cons-threshold most-positive-fixnum)
> (run-with-idle-timer 2 t (lambda () (garbage-collect)))
>
> 4. Run emacs as `HOME=/tmp/ emacs`, evaluate (garbage-collect), then measure its PSS
>
> ## Expected
>
> Size has no statistically-significant difference, because in both
> cases we garbage-collected memory.
I disagree with this expectation: it is perfectly normal for the amount
of memory allocated to the Emacs process to be left higher if you delay
the GC. There are various reasons for that:
- fragmentation, of course. Not much we can do about it short of using
a moving collector.
- the desire to keep memory around rather than return it to the OS,
under the assumption that we'll need it again soon.
And it's not considered as a memory leak as long as that memory has
indeed been needed in the past and that future allocations can still
make use of it.
Eli wrote:
> Thanks, but is it really a good idea to call malloc_trim each time we
> free some chunk of memory?
I think if we want to call `malloc_trim`, the obvious place would be to
do it at the end of `garbage_collect`.
Stefan
This bug report was last modified 3 years and 78 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.