Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ezekielchentnik
Created July 25, 2019 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezekielchentnik/96935d4cd747c4e88798e07f4a4fa484 to your computer and use it in GitHub Desktop.
Save ezekielchentnik/96935d4cd747c4e88798e07f4a4fa484 to your computer and use it in GitHub Desktop.
Leak detection
<!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