Skip to content

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

DEV: Add v8 garbage collection after every call (#38659)

David Taylor82003dbc8f6d
diff --git a/lib/asset_processor.rb b/lib/asset_processor.rb
index 726754465de..bf559d83961 100644
--- a/lib/asset_processor.rb
+++ b/lib/asset_processor.rb
@@ -168,6 +168,7 @@ class AssetProcessor
mutex.synchronize do
result = v8.call(*args, **kwargs)
result = v8.call(fetch_result_call) if fetch_result_call
+ v8.low_memory_notification if GlobalSetting.mini_racer_single_threaded
result
end
rescue MiniRacer::RuntimeError => e
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb
index e933445bf57..35355c7649b 100644
--- a/lib/pretty_text.rb
+++ b/lib/pretty_text.rb
@@ -158,7 +158,10 @@ module PrettyText
end
def self.reset_translations
- v8.eval("__resetTranslationTree()")
+ @mutex.synchronize do
+ v8.eval("__resetTranslationTree()")
+ v8.low_memory_notification if GlobalSetting.mini_racer_single_threaded
+ end
end
def self.reset_context
@@ -699,7 +702,10 @@ module PrettyText
def self.protect
rval = nil
- @mutex.synchronize { rval = yield }
+ @mutex.synchronize do
+ rval = yield
+ v8.low_memory_notification if GlobalSetting.mini_racer_single_threaded
+ end
rval
end