PageRenderTime 22ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/metrics/gc/tests/objGraph.js

http://github.com/zpao/v8monkey
JavaScript | 37 lines | 30 code | 7 blank | 0 comment | 4 complexity | 8811e13e5d5dc3355421d81cb901f263 MD5 | raw file
 1test();
 2
 3function test()
 4{
 5  function generate_big_object_graph()
 6  {
 7    var root = {};
 8    f(root, 17);
 9    return root;
10    function f(parent, depth) {
11      if (depth == 0) 
12          return;
13      --depth;
14
15      f(parent.a = {}, depth);
16      f(parent.b = {}, depth);
17    }
18  }
19
20  function f(obj) {
21    with (obj)
22      return arguments;
23  }
24
25  for(var i = 0; i != 10; ++i) 
26  {
27    gc();
28    var x = null;
29    x = f(generate_big_object_graph());
30
31    gc(); //all used
32
33    x = null;
34
35    gc(); //all free
36  }
37}