Mercurial > MadButterfly
annotate nodejs/testleak.js @ 910:410478ded5d2
Remove debug message
author | wycc |
---|---|
date | Tue, 19 Oct 2010 04:04:52 +0800 |
parents | 586e50f82c1f |
children |
rev | line source |
---|---|
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
772
diff
changeset
|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- |
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
772
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
772
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
3 var mbfly = require("mbfly"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
4 var sys = require("sys"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
5 var cproc = require("child_process"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
6 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
7 function testcase1() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
8 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
|
9 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
10 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
11 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
12 var i; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
13 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
14 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
15 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
16 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
17 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
18 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
19 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
20 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
21 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
22 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
23 coord.remove(); |
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 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
27 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
28 function testcase2() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
29 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
|
30 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
31 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
32 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
33 var i, j; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
34 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
35 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
36 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
37 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
38 for(j = 0; j < 10; j++) |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
39 coord = mbrt.coord_new(coords[i]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
40 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
41 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
42 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
43 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
44 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
45 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
46 coord.remove(); |
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 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
50 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
51 function testcase3() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
52 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
|
53 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
54 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
55 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
56 var shape; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
57 var i, j; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
58 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
59 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
60 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
61 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
62 for(j = 0; j < 10; j++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
63 coord = mbrt.coord_new(coords[i]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
64 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
|
65 coord.add_shape(shape); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
66 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
67 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
68 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
69 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
70 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
71 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
72 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
73 coord.remove(); |
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 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
77 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
78 function testcase4() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
79 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
|
80 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
81 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
82 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
83 var shape; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
84 var i, j; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
85 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
86 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
87 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
88 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
89 for(j = 0; j < 10; j++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
90 coord = mbrt.coord_new(coords[i]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
91 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
|
92 coord.add_shape(shape); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
93 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
94 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
95 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
96 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
97 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
98 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
99 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
100 coord.remove(); |
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 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
104 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
105 function testcase5() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
106 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
|
107 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
108 var paint; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
109 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
110 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
111 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
|
112 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
113 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
114 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
115 function testcase6() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
116 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
|
117 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
118 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
119 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
120 var shape; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
121 var paint; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
122 var i, j; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
123 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
124 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
125 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
126 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
127 /* Paint is free, but rdman is dirty */ |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
128 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
|
129 for(j = 0; j < 10; j++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
130 coord = mbrt.coord_new(coords[i]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
131 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
|
132 coord.add_shape(shape); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
133 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
134 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
135 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
136 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
137 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
138 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
139 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
140 coord.remove(); |
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 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
144 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
145 function testcase7() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
146 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
|
147 var root = mbrt.root; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
148 var coords = []; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
149 var coord; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
150 var shape; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
151 var paint; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
152 var i, j; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
153 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
154 while(true) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
155 for(i = 0; i < 200; i++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
156 coords.push(mbrt.coord_new(root)); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
157 for(j = 0; j < 10; j++) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
158 /* paint is not free, and rdman is dirty */ |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
159 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
|
160 coord = mbrt.coord_new(coords[i]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
161 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
|
162 coord.add_shape(shape); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
163 paint.stroke(shape); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
164 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
165 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
166 mbrt.redraw_changed(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
167 mbrt.flush(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
168 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
169 while(coords.length > 0) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
170 coord = coords.pop(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
171 coord.remove(); |
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 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
175 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
176 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
|
177 setTimeout(function() { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
178 if(process.argv.length == 1) |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
179 testcase1(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
180 else if(process.argv.length == 3) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
181 sys.puts("testcase " + process.argv[2]); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
182 switch(process.argv[2]) { |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
183 case "1": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
184 testcase1(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
185 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
186 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
187 case "2": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
188 testcase2(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
189 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
190 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
191 case "3": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
192 testcase3(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
193 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
194 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
195 case "4": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
196 testcase4(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
197 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
198 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
199 case "5": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
200 testcase5(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
201 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
202 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
203 case "6": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
204 testcase6(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
205 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
206 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
207 case "7": |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
208 testcase7(); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
209 break; |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
210 |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
211 default: |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
212 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
|
213 } |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
214 } else |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
215 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
|
216 cproc.exec("killall -9 Xvfb"); |
11f062c2c0b8
Script to detect memory leaking
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
217 }, 1500); |