Skip to content

A platform for community discussion. Free, open, simple.

PERF: Perform v8 GC immediately before fork (#38544)

David Taylor35aed98eabdf
diff --git a/lib/discourse.rb b/lib/discourse.rb
index ddec22da8cc..dc4437dcd41 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -994,7 +994,9 @@ module Discourse
# before forking, otherwise the forked process might
# be in a bad state
def self.before_fork
- if !GlobalSetting.mini_racer_single_threaded
+ if GlobalSetting.mini_racer_single_threaded
+ ObjectSpace.each_object(MiniRacer::Context) { |c| c.low_memory_notification }
+ else
# V8 does not support forking, make sure all contexts are disposed
ObjectSpace.each_object(MiniRacer::Context) { |c| c.dispose }
end