OLD | NEW |
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* ***** BEGIN LICENSE BLOCK ***** | 2 /* ***** BEGIN LICENSE BLOCK ***** |
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
4 * | 4 * |
5 * The contents of this file are subject to the Mozilla Public License Version | 5 * The contents of this file are subject to the Mozilla Public License Version |
6 * 1.1 (the "License"); you may not use this file except in compliance with | 6 * 1.1 (the "License"); you may not use this file except in compliance with |
7 * the License. You may obtain a copy of the License at | 7 * the License. You may obtain a copy of the License at |
8 * http://www.mozilla.org/MPL/ | 8 * http://www.mozilla.org/MPL/ |
9 * | 9 * |
10 * Software distributed under the License is distributed on an "AS IS" basis, | 10 * Software distributed under the License is distributed on an "AS IS" basis, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 printBugNumber(BUGNUMBER); | 53 printBugNumber(BUGNUMBER); |
54 printStatus (summary); | 54 printStatus (summary); |
55 | 55 |
56 function generate_big_object_graph() | 56 function generate_big_object_graph() |
57 { | 57 { |
58 var root = {}; | 58 var root = {}; |
59 f(root, 17); | 59 f(root, 17); |
60 return root; | 60 return root; |
61 function f(parent, depth) { | 61 function f(parent, depth) { |
62 if (depth == 0) | 62 if (depth == 0) |
63 » return; | 63 return; |
64 --depth; | 64 --depth; |
65 f(parent.a = {}, depth); | 65 f(parent.a = {}, depth); |
66 f(parent.b = {}, depth); | 66 f(parent.b = {}, depth); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 function outer() { var x = arguments; return function inner() { return x }; } | 70 function outer() { var x = arguments; return function inner() { return x }; } |
71 | 71 |
72 function timed_gc() | 72 function timed_gc() |
73 { | 73 { |
74 var t1 = Date.now(); | 74 var t1 = Date.now(); |
75 gc(); | 75 gc(); |
76 return Date.now() - t1; | 76 return Date.now() - t1; |
77 } | 77 } |
78 | 78 |
79 outer(1); | 79 outer(1); |
80 gc(); | 80 gc(); |
81 var base_time = timed_gc(); | 81 var base_time = timed_gc(); |
82 | 82 |
83 var f = outer(generate_big_object_graph()); | 83 var f = outer(generate_big_object_graph()); |
84 f = null; | 84 f = null; |
85 gc(); | 85 gc(); |
86 var time = timed_gc(); | 86 var time = timed_gc(); |
87 | 87 |
88 if (time > (base_time + 1) * 3) | 88 if (time > (base_time + 1) * 3) |
89 throw "generate_big_object_graph() leaked, base_gc_time="+base_time+", last_
gc_time="+time; | 89 actual = "generate_big_object_graph() leaked, base_gc_time="+base_time+", la
st_gc_time="+time; |
90 | 90 |
91 reportCompare(expect, actual, summary); | 91 reportCompare(expect, actual, summary); |
92 | 92 |
93 exitFunc ('test'); | 93 exitFunc ('test'); |
94 } | 94 } |
OLD | NEW |