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 #29 received at 45200 <at> debbugs.gnu.org (full text, mbox):
> From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> Date: Sun, 24 Jan 2021 18:24:02 +0300
>
> configure.ac: check whether malloc_trim is suported
> src/alloc.c (lisp_free): call malloc_trim() if possible
> (bug#45200)
> ---
> configure.ac | 3 +++
> src/alloc.c | 3 +++
> 2 files changed, 6 insertions(+)
>
> diff --git a/configure.ac b/configure.ac
> index bcc0be7de0..3e0459a0e2 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -4544,6 +4544,9 @@ AC_DEFUN
> dnl the current CFLAGS etc.
> AC_CHECK_FUNCS(snprintf)
>
> +
> +AC_CHECK_FUNCS(malloc_trim)
> +
> dnl Check for glib. This differs from other library checks in that
> dnl Emacs need not link to glib unless some other library is already
> dnl linking to glib. Although glib provides no facilities that Emacs
> diff --git a/src/alloc.c b/src/alloc.c
> index c0a55e61b9..97e3ceb52c 100644
> --- a/src/alloc.c
> +++ b/src/alloc.c
> @@ -1047,6 +1047,9 @@ lisp_free (void *block)
>
> MALLOC_BLOCK_INPUT;
> free (block);
> +#ifdef HAVE_MALLOC_TRIM
> + malloc_trim(0); /* work around for high memory consumption, see bug 45200 */
> +#endif /* HAVE_MALLOC_TRIM */
> #ifndef GC_MALLOC_CHECK
> mem_delete (mem_find (block));
> #endif
Thanks, but is it really a good idea to call malloc_trim each time we
free some chunk of memory?
Carlos, Florian, DJ: any thoughts or comments on this proposal? (Let
me know if you need some background about the code involved in this.)
This bug report was last modified 3 years and 79 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.