<!doctype html>
<html>
<head>
<link rel="stylesheet" href="lib/style.css">
<script src="lib/script.js"></script>
</head>
<body>
<script src="/lib/script.js"></script>
<button onclick="measureMemory()">Measure Memory</button>
</body>
</html>
function measureMemory() {
const arraySize = 25 * Math.pow(1000, 2);
console.log(`${performance.memory.usedJSHeapSize / Math.pow(1000, 2)} MB`);
(function() {
const array1 = new Array(arraySize).fill(1.1);
console.log(`${performance.memory.usedJSHeapSize / Math.pow(1000, 2)} MB`);
})();
(function() {
const array2 = new Array(arraySize).fill(1);
console.log(`Maybe after GC: ${performance.memory.usedJSHeapSize / Math.pow(1000, 2)} MB`);
})();
setTimeout(() => {
console.log(`After GC: ${performance.memory.usedJSHeapSize / Math.pow(1000, 2)} MB`);
}, 5000);
}