MCPcopy
hub / github.com/mongodb/node-mongodb-native / main

Function main

test/tools/fixtures/heap_resource_script.in.js:33–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31};
32
33async function main() {
34 log('starting execution');
35 const startingMemoryUsed = process.memoryUsage().heapUsed / MB;
36 process.send({ startingMemoryUsed });
37
38 log('sent first message');
39
40 for (let iteration = 0; iteration < iterations; iteration++) {
41 await run({ MongoClient, uri, iteration });
42 iteration % 20 === 0 && log(`iteration ${iteration} complete`);
43 global.gc();
44 }
45
46 log('script executed');
47
48 global.gc();
49 // Sleep b/c maybe gc will run
50 await sleep(100);
51 global.gc();
52
53 const endingMemoryUsed = process.memoryUsage().heapUsed / MB;
54
55 log('sending second message');
56
57 process.send({ endingMemoryUsed });
58 log('second message sent.');
59
60 const clientsInMemory = v8.queryObjects(MongoClient);
61
62 process.send({ clientsInMemory });
63
64 log('clients instances in memory sent.');
65}
66
67main()
68 .then(() => {

Callers 1

Calls 2

logFunction · 0.70
runFunction · 0.50

Tested by

no test coverage detected