Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Leak detection
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Memory Leak</title>
<h1>Memory Leak</h1>
<p>Click Start to run the script</p>
<button id="leak-button">Start</button>
<button id="stop-button">Stop</button>
let x = [];
let runing = false;
const leakButton = document.getElementById('leak-button');
const stopButton = document.getElementById('stop-button');
function grow(){
x.push(new Array(1000000).join('leak'));
if(running) {
setTimeout(grow, 1000)
leakButton.addEventListener('click', () => {
running = true;
leakButton.addEventListener('click', () => {
running = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment