Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / devtools / server / tests / chrome / test_memory_gc_01.html
blob8b2f049602156060c5900b0df9f97476d99c7a9b
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 Bug 1067491 - Test forcing a gc.
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Memory monitoring actor test</title>
9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
11 </head>
12 <body>
13 <pre id="test">
14 <script src="memory-helpers.js" type="application/javascript"></script>
15 <script>
16 "use strict";
18 window.onload = function() {
19 SimpleTest.waitForExplicitFinish();
21 (async function() {
22 const { memory, target } = await startServerAndGetSelectedTabMemory();
24 let beforeGC, afterGC;
26 do {
27 let objects = [];
28 for (let i = 0; i < 1000; i++) {
29 const o = {};
30 o[Math.random()] = 1;
31 objects.push(o);
33 objects = null;
35 beforeGC = (await memory.measure()).total;
37 await memory.forceGarbageCollection();
39 afterGC = (await memory.measure()).total;
40 } while (beforeGC < afterGC);
42 ok(true, "The amount of memory after GC should eventually decrease");
44 destroyServerAndFinish(target);
45 })();
47 </script>
48 </pre>
49 </body>
50 </html>