Maintenance: Reduce memory consumption by setting MALLOC_ARENA_MAX.

The Zammad environment variable `MALLOC_ARENA_MAX` will now default to `2`. This environment variable was previously unset.

The goal of setting this value is to decrease memory usage for the majority of Zammad installations - especially the Worker and Puma processes. To understand more about the relationship between this value and memory please see the following external resources:

- https://www.speedshop.co/2017/12/04/malloc-doubles-ruby-memory.html
- https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/

Heroku also maintains a [documentation on tuning the memory behavior of glibc by setting this environment variable](https://devcenter.heroku.com/articles/tuning-glibc-memory-behavior).

The default as specified by the [linux man page](http://man7.org/linux/man-pages/man3/mallopt.3.html) is 8 times the number of (virtual) cores on the system.
This commit is contained in:
Thorsten Eckel 2019-10-29 14:49:03 +01:00
parent d4afb0e867
commit def0525c6d

View file

@ -299,6 +299,7 @@ function update_or_install () {
}
function set_env_vars () {
zammad config:set RUBY_MALLOC_ARENA_MAX=${ZAMMAD_RUBY_MALLOC_ARENA_MAX:=2}
zammad config:set RUBY_GC_MALLOC_LIMIT=${ZAMMAD_RUBY_GC_MALLOC_LIMIT:=1077216}
zammad config:set RUBY_GC_MALLOC_LIMIT_MAX=${ZAMMAD_RUBY_GC_MALLOC_LIMIT_MAX:=2177216}
zammad config:set RUBY_GC_OLDMALLOC_LIMIT=${ZAMMAD_RUBY_GC_OLDMALLOC_LIMIT:=2177216}