-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e82bd16
commit a862fc0
Showing
3 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
module MiniRacer | ||
VERSION = "0.17.0.pre2" | ||
LIBV8_NODE_VERSION = "~> 22.7.0.3" | ||
VERSION = "0.17.0.pre3" | ||
LIBV8_NODE_VERSION = "~> 22.7.0.4" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# use bundle exec to run this script | ||
# | ||
require 'securerandom' | ||
|
||
|
||
context = nil | ||
|
||
Thread.new do | ||
require "mini_racer" | ||
context = MiniRacer::Context.new | ||
end.join | ||
|
||
Thread.new do | ||
context.isolate.low_memory_notification | ||
|
||
start_heap = context.heap_stats[:used_heap_size] | ||
|
||
context.eval("'#{"x" * 1_000_000_0}'") | ||
|
||
|
||
end_heap = context.heap_stats[:used_heap_size] | ||
|
||
p end_heap - start_heap | ||
end.join | ||
|
||
Thread.new do | ||
10.times do | ||
context.isolate.low_memory_notification | ||
end | ||
end_heap = context.heap_stats[:used_heap_size] | ||
p end_heap | ||
end.join | ||
exit | ||
|
||
|
||
ctx = nil | ||
|
||
big_eval = +"" | ||
|
||
(0..100).map do |j| | ||
big_regex = (1..10000).map { |i| SecureRandom.hex }.join("|") | ||
big_eval << "X[#{j}] = /#{big_regex}/;\n" | ||
end | ||
|
||
big_eval = <<~JS | ||
const X = []; | ||
#{big_eval} | ||
function test(i, str) { | ||
return X[i].test(str); | ||
} | ||
null; | ||
JS | ||
|
||
Thread | ||
.new do | ||
require "mini_racer" | ||
ctx = MiniRacer::Context.new | ||
ctx.eval("var a = 1+1") | ||
ctx.eval(big_eval) | ||
end | ||
.join | ||
|
||
3.times { GC.start } | ||
|
||
|
||
Thread | ||
.new do | ||
10.times do | ||
10.times { |i| p ctx.eval "test(#{i}, '#{SecureRandom.hex}')" } | ||
end | ||
end | ||
.join | ||
|
||
GC.start |