1
0
Fork 0
mirror of https://github.com/rubyjs/mini_racer synced 2023-03-27 23:21:28 -04:00
mini_racer/test/test_forking.rb
Sam Saffron d968ee5857
FEATURE: re-add support for single threaded platform
Previously this was removed cause V8 was lagging. Now that we have latest
v8 we can use this feature.
2022-01-10 17:21:40 +11:00

28 lines
569 B
Ruby

# use bundle exec to run this script
require 'mini_racer'
MiniRacer::Platform.set_flags! :single_threaded
@ctx = MiniRacer::Context.new
@ctx.eval("var a = 1+1")
def trigger_gc
puts "a"
ctx = MiniRacer::Context.new
puts "b"
ctx.eval("var a = #{('x' * 100000).inspect}")
puts "c"
ctx.eval("a = undefined")
puts "d"
ctx.isolate.low_memory_notification
puts "f"
puts "done triggering"
end
trigger_gc
MiniRacer::Context.new.dispose
Process.wait fork { puts @ctx.eval("a"); @ctx.dispose; puts Process.pid; trigger_gc; puts "done #{Process.pid}" }