mirror of
https://github.com/rubyjs/mini_racer
synced 2023-03-27 23:21:28 -04:00

Previously this was removed cause V8 was lagging. Now that we have latest v8 we can use this feature.
28 lines
569 B
Ruby
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}" }
|
|
|
|
|