Mercurial > MadButterfly
annotate nodejs/testleak.js @ 772:11f062c2c0b8
Script to detect memory leaking
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 29 Aug 2010 19:13:59 +0800 |
parents | |
children | 586e50f82c1f |
rev | line source |
---|---|
772
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
1 var mbfly = require("mbfly"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
2 var sys = require("sys"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
3 var cproc = require("child_process"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
4 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
5 function testcase1() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
6 var mbrt = new mbfly.mb_rt(":32.0", 300, 200); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
7 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
8 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
9 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
10 var i; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
11 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
12 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
13 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
14 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
15 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
16 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
17 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
18 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
19 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
20 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
21 coord.remove(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
22 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
23 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
24 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
25 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
26 function testcase2() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
27 var mbrt = new mbfly.mb_rt(":32.0", 300, 200); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
28 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
29 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
30 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
31 var i, j; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
32 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
33 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
34 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
35 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
36 for(j = 0; j < 10; j++) |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
37 coord = mbrt.coord_new(coords[i]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
38 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
39 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
40 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
41 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
42 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
43 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
44 coord.remove(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
45 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
46 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
47 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
48 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
49 function testcase3() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
50 var mbrt = new mbfly.mb_rt(":32.0", 300, 200); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
51 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
52 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
53 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
54 var shape; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
55 var i, j; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
56 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
57 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
58 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
59 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
60 for(j = 0; j < 10; j++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
61 coord = mbrt.coord_new(coords[i]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
62 shape = mbrt.rect_new(15, 15, 20, 20, 0, 0); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
63 coord.add_shape(shape); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
64 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
65 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
66 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
67 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
68 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
69 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
70 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
71 coord.remove(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
72 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
73 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
74 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
75 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
76 function testcase4() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
77 var mbrt = new mbfly.mb_rt(":32.0", 300, 200); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
78 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
79 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
80 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
81 var shape; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
82 var i, j; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
83 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
84 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
85 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
86 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
87 for(j = 0; j < 10; j++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
88 coord = mbrt.coord_new(coords[i]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
89 shape = mbrt.path_new("m 10,10 l 55,27 l -30,-3 z"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
90 coord.add_shape(shape); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
91 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
92 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
93 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
94 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
95 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
96 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
97 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
98 coord.remove(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
99 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
100 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
101 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
102 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
103 function testcase5() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
104 var mbrt = new mbfly.mb_rt(":32.0", 300, 200); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
105 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
106 var paint; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
107 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
108 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
109 paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
110 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
111 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
112 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
113 function testcase6() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
114 var mbrt = new mbfly.mb_rt(":32.0", 300, 200); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
115 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
116 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
117 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
118 var shape; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
119 var paint; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
120 var i, j; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
121 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
122 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
123 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
124 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
125 /* Paint is free, but rdman is dirty */ |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
126 paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
127 for(j = 0; j < 10; j++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
128 coord = mbrt.coord_new(coords[i]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
129 shape = mbrt.rect_new(5, 5, 20, 20, 0, 0); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
130 coord.add_shape(shape); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
131 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
132 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
133 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
134 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
135 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
136 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
137 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
138 coord.remove(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
139 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
140 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
141 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
142 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
143 function testcase7() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
144 var mbrt = new mbfly.mb_rt(":32.0", 300, 200); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
145 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
146 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
147 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
148 var shape; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
149 var paint; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
150 var i, j; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
151 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
152 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
153 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
154 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
155 for(j = 0; j < 10; j++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
156 /* paint is not free, and rdman is dirty */ |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
157 paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
158 coord = mbrt.coord_new(coords[i]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
159 shape = mbrt.path_new("M 100,100 L 30,30 L 0,30 z"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
160 coord.add_shape(shape); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
161 paint.stroke(shape); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
162 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
163 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
164 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
165 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
166 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
167 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
168 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
169 coord.remove(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
170 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
171 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
172 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
173 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
174 cproc.exec("killall -9 Xvfb; Xvfb :32 -screen 0 800x600x24"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
175 setTimeout(function() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
176 if(process.argv.length == 1) |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
177 testcase1(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
178 else if(process.argv.length == 3) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
179 sys.puts("testcase " + process.argv[2]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
180 switch(process.argv[2]) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
181 case "1": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
182 testcase1(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
183 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
184 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
185 case "2": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
186 testcase2(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
187 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
188 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
189 case "3": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
190 testcase3(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
191 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
192 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
193 case "4": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
194 testcase4(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
195 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
196 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
197 case "5": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
198 testcase5(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
199 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
200 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
201 case "6": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
202 testcase6(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
203 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
204 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
205 case "7": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
206 testcase7(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
207 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
208 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
209 default: |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
210 sys.puts("Usage: node testleak.js [1|2|3...7]"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
211 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
212 } else |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
213 sys.puts("Usage: node testleak.js [1|2|3...7]"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
214 cproc.exec("killall -9 Xvfb"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
215 }, 1500); |