2012-05-01 14:53:01 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "A Very blunt test to make sure that we aren't doing stupid leaks" do
|
|
|
|
before do
|
2012-05-03 13:56:41 -04:00
|
|
|
#allocate a single context to make sure that v8 loads its snapshot and
|
|
|
|
#we pay the overhead.
|
|
|
|
V8::Context.new
|
2012-05-01 14:53:01 -04:00
|
|
|
@start_memory = process_memory
|
|
|
|
GC.stress = true
|
|
|
|
end
|
2012-05-03 03:24:15 -04:00
|
|
|
|
2012-05-01 14:53:01 -04:00
|
|
|
after do
|
|
|
|
GC.stress = false
|
|
|
|
end
|
2012-05-03 13:56:41 -04:00
|
|
|
it "won't increase process memory by more than 20% no matter how many contexts we create" do
|
|
|
|
5000.times do
|
|
|
|
V8::Context.new
|
2012-05-08 16:11:50 -04:00
|
|
|
run_v8_gc
|
2012-05-01 14:53:01 -04:00
|
|
|
end
|
2012-05-11 11:42:07 -04:00
|
|
|
process_memory.should <= @start_memory * 1.5
|
2012-05-01 14:53:01 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def process_memory
|
|
|
|
/\w*[ ]*#{Process.pid}[ ]*([.,\d]*)[ ]*([.,\d]*)[ ]*([\d]*)[ ]*([\d]*)/.match(`ps aux`)[4].to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|