File tree 1 file changed +5
-8
lines changed
1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ const assert = require('assert');
27
27
const vm = require ( 'vm' ) ;
28
28
29
29
const start = Date . now ( ) ;
30
- let maxMem = 0 ;
31
30
32
31
const interval = setInterval ( function ( ) {
33
32
try {
@@ -36,22 +35,20 @@ const interval = setInterval(function() {
36
35
}
37
36
38
37
const rss = process . memoryUsage ( ) . rss ;
39
- maxMem = Math . max ( rss , maxMem ) ;
38
+ assert . ok ( rss < 64 * 1024 * 1024 ,
39
+ `memory usage: ${ Math . round ( rss / ( 1024 * 1024 ) ) } Mb` ) ;
40
40
41
+ // Stop after 5 seconds.
41
42
if ( Date . now ( ) - start > 5 * 1000 ) {
42
- // wait 10 seconds.
43
43
clearInterval ( interval ) ;
44
44
45
45
testContextLeak ( ) ;
46
46
}
47
47
} , 1 ) ;
48
48
49
49
function testContextLeak ( ) {
50
+ // TODO: This needs a comment explaining what it's doing. Will it crash the
51
+ // test if there is a memory leak? Or what?
50
52
for ( let i = 0 ; i < 1000 ; i ++ )
51
53
vm . createContext ( { } ) ;
52
54
}
53
-
54
- process . on ( 'exit' , function ( ) {
55
- console . error ( `max mem: ${ Math . round ( maxMem / ( 1024 * 1024 ) ) } mb` ) ;
56
- assert . ok ( maxMem < 64 * 1024 * 1024 ) ;
57
- } ) ;
You can’t perform that action at this time.
0 commit comments