Skip to content

Commit

Permalink
Make something JIT'd to increase executable heap size
Browse files Browse the repository at this point in the history
  • Loading branch information
lloeki committed Apr 22, 2024
1 parent 8c9bb5d commit 3754b17
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/mini_racer_test.rb
Expand Up @@ -729,7 +729,13 @@ def test_can_dispose_context
def test_estimated_size
skip "TruffleRuby does not yet implement heap_stats" if RUBY_ENGINE == "truffleruby"
context = MiniRacer::Context.new(timeout: 5)
context.eval("let a='testing';")
context.eval(<<-JS)
let a='testing';
let f=function(foo) { foo + 42 };
// call `f` a lot to have things JIT'd so that total_heap_size_executable becomes > 0
for (let i = 0; i < 1000000; i++) { f(10); }
JS

stats = context.heap_stats
# eg: {:total_physical_size=>1280640, :total_heap_size_executable=>4194304, :total_heap_size=>3100672, :used_heap_size=>1205376, :heap_size_limit=>1501560832}
Expand Down

0 comments on commit 3754b17

Please sign in to comment.