From 76173dea87115589414a200ad7fc1f08a4deb280 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Thu, 16 May 2019 09:50:22 +1000 Subject: [PATCH] DEV: ensure we never fork v8 contexts from unicorn v8 forking is not supported and can lead to memory leaks. This commit handles the most common case which is the unicorn master forking There are still some cases related to backup where we fork, however those forks are usually short lived so the memory leak is not severe, burning the contexts in the master process could break sidekiq or web process that do the actual forking --- config/unicorn.conf.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/unicorn.conf.rb b/config/unicorn.conf.rb index e6e2d616b48..85b28005f5a 100644 --- a/config/unicorn.conf.rb +++ b/config/unicorn.conf.rb @@ -69,6 +69,9 @@ before_fork do |server, worker| Discourse.git_branch Discourse.full_version + # V8 does not support forking, make sure all contexts are disposed + ObjectSpace.each_object(MiniRacer::Context) { |c| c.dispose } + # get rid of rubbish so we don't share it GC.start