test_memory_gc_01.html (1162B)
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"; 17 18 window.onload = function() { 19 SimpleTest.waitForExplicitFinish(); 20 21 (async function() { 22 const { memory, target } = await startServerAndGetSelectedTabMemory(); 23 24 let beforeGC, afterGC; 25 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); 32 } 33 objects = null; 34 35 beforeGC = (await memory.measure()).total; 36 37 await memory.forceGarbageCollection(); 38 39 afterGC = (await memory.measure()).total; 40 } while (beforeGC < afterGC); 41 42 ok(true, "The amount of memory after GC should eventually decrease"); 43 44 destroyServerAndFinish(target); 45 })(); 46 }; 47 </script> 48 </pre> 49 </body> 50 </html>