diff --git a/Changelog.md b/Changelog.md index eca833b6d..d579834b5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,6 +11,7 @@ ## Features * Add the ability to assign roles in the admin panel [#7868](https://github.com/diaspora/diaspora/pull/7868) +* Improve memory usage with libjemalloc if available [#7919](https://github.com/diaspora/diaspora/pull/7919) # 0.7.7.0 diff --git a/script/server b/script/server index eb8b92294..9cc8ee51a 100755 --- a/script/server +++ b/script/server @@ -202,6 +202,21 @@ diaspora.yml.example " fi +# Use libjemalloc if it's available for better memory usage +command -v ldconfig > /dev/null 2>&1 +if [ $? -eq 0 ]; then + ldconfig=ldconfig +elif [ -x /sbin/ldconfig ]; then + ldconfig=/sbin/ldconfig +fi +if [ -n "${ldconfig}" ]; then + jemalloc_path=$(${ldconfig} -p | grep jemalloc | tr ' ' '\n' | grep '^/' | head -1) + + if [ -n "${jemalloc_path}" ]; then + export LD_PRELOAD="${jemalloc_path}" + fi +fi + # Start Diaspora printf "Starting Diaspora in $RAILS_ENV mode " if [ -n "$PORT" ]