mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
make sure that simple evaluation does not leak
This commit is contained in:
parent
47a9461e23
commit
bcabe39866
1 changed files with 12 additions and 3 deletions
|
@ -2,6 +2,9 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe "A Very blunt test to make sure that we aren't doing stupid leaks" do
|
describe "A Very blunt test to make sure that we aren't doing stupid leaks" do
|
||||||
before 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
|
#allocate a single context to make sure that v8 loads its snapshot and
|
||||||
#we pay the overhead.
|
#we pay the overhead.
|
||||||
V8::Context.new
|
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
|
GC.stress = false
|
||||||
end
|
end
|
||||||
it "won't increase process memory by more than 50% no matter how many contexts we create" do
|
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
|
500.times do
|
||||||
V8::Context.new
|
V8::Context.new
|
||||||
run_v8_gc
|
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
|
process_memory.should <= @start_memory * 1.5
|
||||||
end
|
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
|
def process_memory
|
||||||
/\w*[ ]*#{Process.pid}[ ]*([.,\d]*)[ ]*([.,\d]*)[ ]*([\d]*)[ ]*([\d]*)/.match(`ps aux`)[4].to_i
|
/\w*[ ]*#{Process.pid}[ ]*([.,\d]*)[ ]*([.,\d]*)[ ]*([\d]*)[ ]*([\d]*)/.match(`ps aux`)[4].to_i
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue