mirror of
https://github.com/tmux/tmux.git
synced 2025-04-13 14:58:50 +00:00
glibc's malloc is very bad about returning memory from the kernel, add a call
to its malloc_trim to prompt it to do so. Reported by Sarunas Valaskevicius.
This commit is contained in:
parent
847a061e31
commit
680e7a382f
4
compat.h
4
compat.h
@ -27,6 +27,10 @@
|
|||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_MALLOC_TRIM
|
||||||
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UTF8PROC
|
#ifdef HAVE_UTF8PROC
|
||||||
#include <utf8proc.h>
|
#include <utf8proc.h>
|
||||||
#endif
|
#endif
|
||||||
|
25
configure.ac
25
configure.ac
@ -328,6 +328,31 @@ AC_SEARCH_LIBS(inet_ntoa, nsl)
|
|||||||
AC_SEARCH_LIBS(socket, socket)
|
AC_SEARCH_LIBS(socket, socket)
|
||||||
AC_CHECK_LIB(xnet, socket)
|
AC_CHECK_LIB(xnet, socket)
|
||||||
|
|
||||||
|
# Check if using glibc and have malloc_trim(3). The glibc free(3) is pretty bad
|
||||||
|
# about returning memory to the kernel unless the application tells it when to
|
||||||
|
# with malloc_trim(3).
|
||||||
|
AC_MSG_CHECKING(if free doesn't work very well)
|
||||||
|
AC_LINK_IFELSE([AC_LANG_SOURCE(
|
||||||
|
[
|
||||||
|
#include <stdlib.h>
|
||||||
|
#ifdef __GLIBC__
|
||||||
|
#include <malloc.h>
|
||||||
|
int main(void) {
|
||||||
|
malloc_trim (0);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
no
|
||||||
|
#endif
|
||||||
|
])],
|
||||||
|
found_malloc_trim=yes,
|
||||||
|
found_malloc_trim=no
|
||||||
|
)
|
||||||
|
AC_MSG_RESULT($found_malloc_trim)
|
||||||
|
if test "x$found_malloc_trim" = xyes; then
|
||||||
|
AC_DEFINE(HAVE_MALLOC_TRIM)
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for CMSG_DATA. On some platforms like HP-UX this requires UNIX 95
|
# Check for CMSG_DATA. On some platforms like HP-UX this requires UNIX 95
|
||||||
# (_XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED) (see xopen_networking(7)). On
|
# (_XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED) (see xopen_networking(7)). On
|
||||||
# others, UNIX 03 (_XOPEN_SOURCE 600, see standards(7) on Solaris).
|
# others, UNIX 03 (_XOPEN_SOURCE 600, see standards(7) on Solaris).
|
||||||
|
3
grid.c
3
grid.c
@ -265,6 +265,9 @@ grid_free_lines(struct grid *gd, u_int py, u_int ny)
|
|||||||
|
|
||||||
for (yy = py; yy < py + ny; yy++)
|
for (yy = py; yy < py + ny; yy++)
|
||||||
grid_free_line(gd, yy);
|
grid_free_line(gd, yy);
|
||||||
|
#ifdef HAVE_MALLOC_TRIM
|
||||||
|
malloc_trim(0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a new grid. */
|
/* Create a new grid. */
|
||||||
|
Loading…
Reference in New Issue
Block a user