Created
July 1, 2016 23:19
-
-
Save mohayonao/fd25c883f17ddeb365e2a8725e036d2f to your computer and use it in GitHub Desktop.
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> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>memory leak</title> | |
| </head> | |
| <body> | |
| <button id="test">test</button> | |
| <div id="debug"></div> | |
| <script src="build/web-audio-engine-old.js"></script> | |
| <script> | |
| window.addEventListener("DOMContentLoaded", () => { | |
| "use strict"; | |
| var audioContext = new WebAudioEngine.WebAudioContext({ context: new AudioContext() }); | |
| var $debug = document.getElementById("debug"); | |
| function beep() { | |
| var t0 = audioContext.currentTime; | |
| var t1 = t0 + 0.05; | |
| var oscillator = audioContext.createOscillator(); | |
| var gain = audioContext.createGain(); | |
| oscillator.start(t0); | |
| oscillator.stop(t1); | |
| oscillator.connect(gain); | |
| gain.gain.value = 0; | |
| gain.connect(audioContext.destination); | |
| } | |
| document.getElementById("test").addEventListener("click", () => { | |
| var counter = 0; | |
| $debug.textContent = "RUNNING"; | |
| function loop() { | |
| beep(); | |
| counter += 1; | |
| if (counter < 10000) { | |
| setTimeout(loop, 0); | |
| } else { | |
| $debug.textContent = "END"; | |
| } | |
| } | |
| loop(); | |
| }); | |
| audioContext.resume(); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment