diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-28 00:27:08 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-28 00:27:08 +0200 |
commit | 973e50d1f43b680863551f1aea30d88616488e84 (patch) | |
tree | 29bf0ae53e1e794ddbd1c8965e6b09f4ac38141e /src | |
parent | b3ae8e299517556ec6e9ad06d91353f5b66d0827 (diff) | |
download | sciteco-973e50d1f43b680863551f1aea30d88616488e84.tar.gz |
FreeBSD/jemalloc: fixed recovery after hitting memory limit
* We now set opt.retain=false for the process, so jemalloc returns
freed memory and the RSS decreases when recovering from memory limit hits.
This should be safe at least on FreeBSD.
* Either the opt.retain option is new or I was previously testing
this only on 32-bit systems.
Diffstat (limited to 'src')
-rw-r--r-- | src/memory.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/memory.c b/src/memory.c index 605c221..26cde55 100644 --- a/src/memory.c +++ b/src/memory.c @@ -495,6 +495,16 @@ teco_memory_get_usage(void) return procstk.ki_rssize * page_size; } +/** + * Options passed to jemalloc. + * + * It's crucial to disable opt.retain, so that freeing memory after + * recovering from memory limit hits actually decreases the RSS. + * The reasons for activating the option, mentioned in jemalloc(3), + * shouldn't be relevant on FreeBSD. + */ +const gchar *malloc_conf = "retain:false"; + #define NEED_POLL_THREAD #elif defined(G_OS_UNIX) && defined(HAVE_SYSCONF) && defined(HAVE_PROCFS) |