forked from mongodb/mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory.js
31 lines (25 loc) · 870 Bytes
/
memory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// test creating many collections to make sure no internal cache goes OOM
for (var i = 0; i < 10000; ++i) {
name = "foo" + i;
if ((i % 1000) == 0) print("Processing " + name);
db.eval(function(col) { for (var i = 0; i < 100; ++i) {db[col + "_" + i].find();} }, name);
}
// JS engine should recover and allow more querying
// but doesnt work with v8, all calls fail afterwards even form a different context
if ( typeof _threadInject == "undefined" ) {
// test recovery of JS engine after out of memory
db.system.js.save( { "_id" : "f1", "value" : function(n) {
a = [];
b = [];
c = [];
for (i = 0; i < n; i++) {
a.push(Math.random());
b.push(Math.random());
c.push(Math.random());
}
} })
db.eval("f1(10)");
assert.throws(function() { db.eval("f1(100000000)"); } );
db.eval("f1(10)");
db.eval("f1(1000000)");
}