mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-28 10:56:36 +00:00
Add new function `malloc-trim'
* configure.ac (PGTK_LIBS): Check for malloc_trim. * src/alloc.c (Fmalloc_trim): Add new function (bug#45200).
This commit is contained in:
parent
6984f325bd
commit
29f3d4d2c6
@ -2939,6 +2939,8 @@ fi
|
||||
AC_SUBST(PGTK_OBJ)
|
||||
AC_SUBST(PGTK_LIBS)
|
||||
|
||||
AC_CHECK_FUNCS(malloc_trim)
|
||||
|
||||
dnl D-Bus has been tested under GNU/Linux only. Must be adapted for
|
||||
dnl other platforms.
|
||||
HAVE_DBUS=no
|
||||
|
5
etc/NEWS
5
etc/NEWS
@ -1544,6 +1544,11 @@ functions.
|
||||
|
||||
* Lisp Changes in Emacs 29.1
|
||||
|
||||
---
|
||||
** New function 'malloc-trim'.
|
||||
This function allows returning unused memory back to the operating
|
||||
system, and is mainly meant as a debugging tool.
|
||||
|
||||
---
|
||||
** 'x-show-tip' no longer hard-codes a timeout default.
|
||||
The new 'x-show-tooltip-timeout' variable allows the user to alter
|
||||
|
34
src/alloc.c
34
src/alloc.c
@ -7479,6 +7479,37 @@ arenas. */)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MALLOC_TRIM
|
||||
DEFUN ("malloc-trim", Fmalloc_trim, Smalloc_trim, 0, 1, "",
|
||||
doc: /* Release free memory from the heap.
|
||||
This function asks libc to return unused memory back to the operating
|
||||
system. This function isn't guaranteed to do anything, and is mainly
|
||||
meant as a debugging tool.
|
||||
|
||||
If LEAVE_PADDING is given, ask the system to leave that much unused
|
||||
spaced in the heap. This should be an integer, and if not given,
|
||||
defaults to 0.
|
||||
|
||||
This function returns nil if no memory could be returned to the
|
||||
system, and non-nil if some memory could be returned. */)
|
||||
(Lisp_Object leave_padding)
|
||||
{
|
||||
int pad = 0;
|
||||
|
||||
if (! NILP (leave_padding))
|
||||
{
|
||||
CHECK_FIXNAT (leave_padding);
|
||||
pad = XFIXNUM (leave_padding);
|
||||
}
|
||||
|
||||
/* 1 means that memory was released to the system. */
|
||||
if (malloc_trim (pad) == 1)
|
||||
return Qt;
|
||||
else
|
||||
return Qnil;
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool
|
||||
symbol_uses_obj (Lisp_Object symbol, Lisp_Object obj)
|
||||
{
|
||||
@ -7829,6 +7860,9 @@ N should be nonnegative. */);
|
||||
(__GLIBC__ > 2 || __GLIBC_MINOR__ >= 10)
|
||||
|
||||
defsubr (&Smalloc_info);
|
||||
#endif
|
||||
#ifdef HAVE_MALLOC_TRIM
|
||||
defsubr (&Smalloc_trim);
|
||||
#endif
|
||||
defsubr (&Ssuspicious_object);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user