aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-03 11:48:18 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-03 11:48:18 +0000
commit2195e2cf713f974c8774d23ae47e35ea7117e0e1 (patch)
tree080b31ab6770ac76edea6a02109a50ccde35d367
parentREADME: updates (diff)
terminal: trim memory after free:ing a terminal
A terminal with lots of scrollback history will have allocated a lot of memory. Normally, free() wont return this memory to the OS, and we don't seem to trigger the automatic trim calls. This means the server would accumulate quite a lot of memory over time, as terminals come and go. Now we explicitly trim the memory every time a terminal is destroyed.
-rw-r--r--terminal.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/terminal.c b/terminal.c
index 8d5e195f..56cf8d69 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1,5 +1,6 @@
#include "terminal.h"
+#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
@@ -796,6 +797,8 @@ term_destroy(struct terminal *term)
}
free(term);
+ if (!malloc_trim(0))
+ LOG_WARN("failed to trim memory");
return ret;
}