From bcabe3986682885ae45fcd894d21d792358e94f0 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Thu, 7 Jun 2012 05:19:24 -0500 Subject: [PATCH] make sure that simple evaluation does not leak --- spec/mem/blunt_spec.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/spec/mem/blunt_spec.rb b/spec/mem/blunt_spec.rb index 25afc30..c27a5e9 100644 --- a/spec/mem/blunt_spec.rb +++ b/spec/mem/blunt_spec.rb @@ -2,6 +2,9 @@ require 'spec_helper' describe "A Very blunt test to make sure that we aren't doing stupid leaks" do before do + if Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE == 'rbx' + pending 'need to figure out how to do memory sanity checks on rbx' + end #allocate a single context to make sure that v8 loads its snapshot and #we pay the overhead. V8::Context.new @@ -13,9 +16,6 @@ describe "A Very blunt test to make sure that we aren't doing stupid leaks" do GC.stress = false end it "won't increase process memory by more than 50% no matter how many contexts we create" do - if Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE == 'rbx' - pending 'need to figure out how to do memory sanity checks on rbx' - end 500.times do V8::Context.new run_v8_gc @@ -23,6 +23,15 @@ describe "A Very blunt test to make sure that we aren't doing stupid leaks" do process_memory.should <= @start_memory * 1.5 end + it "can eval simple value passing statements repeatedly without significantly increasing memory" do + cxt = V8::Context.new + 500.times do + cxt.eval('7 * 6') + run_v8_gc + end + process_memory.should <= @start_memory * 1.1 + end + def process_memory /\w*[ ]*#{Process.pid}[ ]*([.,\d]*)[ ]*([.,\d]*)[ ]*([\d]*)[ ]*([\d]*)/.match(`ps aux`)[4].to_i end