mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-01 07:15:32 -04:00
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.
This commit is contained in:
parent
ffadb5f020
commit
2195e2cf71
1 changed files with 3 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
|
||||||
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
@ -796,6 +797,8 @@ term_destroy(struct terminal *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
free(term);
|
free(term);
|
||||||
|
if (!malloc_trim(0))
|
||||||
|
LOG_WARN("failed to trim memory");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue