Created
July 25, 2019 15:31
-
-
Save ezekielchentnik/96935d4cd747c4e88798e07f4a4fa484 to your computer and use it in GitHub Desktop.
Leak detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<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> | |
</head> | |
<body> | |
<h1>Memory Leak</h1> | |
<p>Click Start to run the script</p> | |
<button id="leak-button">Start</button> | |
<button id="stop-button">Stop</button> | |
<script> | |
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; | |
grow(); | |
}); | |
leakButton.addEventListener('click', () => { | |
running = false; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment