aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2021-03-11 08:39:41 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2021-03-11 08:39:41 +0000
commitef9700816fd2bd521bab837ccd85e0a596aa3aa8 (patch)
treede386512df432a5f47010bca6b0f1720fe4b103b
parent12cfd0d22b630ead9c6d739b13c3409485ea551c (diff)
downloadrtmux-ef9700816fd2bd521bab837ccd85e0a596aa3aa8.tar.gz
rtmux-ef9700816fd2bd521bab837ccd85e0a596aa3aa8.tar.bz2
rtmux-ef9700816fd2bd521bab837ccd85e0a596aa3aa8.zip
malloc_trim is itself very poor and gets slower and slower as the heap becomes
more fragmented. Run it only once an hour. GitHub issue 2551.
-rw-r--r--grid.c3
-rw-r--r--server.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/grid.c b/grid.c
index 1822f2b5..7744587a 100644
--- a/grid.c
+++ b/grid.c
@@ -265,9 +265,6 @@ grid_free_lines(struct grid *gd, u_int py, u_int ny)
for (yy = py; yy < py + ny; yy++)
grid_free_line(gd, yy);
-#ifdef HAVE_MALLOC_TRIM
- malloc_trim(0);
-#endif
}
/* Create a new grid. */
diff --git a/server.c b/server.c
index ab8c6574..0b878d9e 100644
--- a/server.c
+++ b/server.c
@@ -159,6 +159,10 @@ server_tidy_event(__unused int fd, __unused short events, __unused void *data)
format_tidy_jobs();
+#ifdef HAVE_MALLOC_TRIM
+ malloc_trim(0);
+#endif
+
log_debug("%s: took %llu milliseconds", __func__, get_timer() - t);
evtimer_add(&server_ev_tidy, &tv);
}