title: Web Audio api Oscillator Causes a memory leak
body: <p>I am trying to make an accordion-like (and other instruments) sound using web audio api oscillators and effects, and I got it to sound decent enough, however playing the sound multiples times causes a big memory leak, as none of the objects seem to be disposed. I got the page to use up to 2Gb of ram. I have no ideea what causes this. This is the code which causes the leak</p>
  <pre><code>async function play_accordion2(freq,start_time,dur,volume)
  {     
      let wave_ethnic = audioCtx.createPeriodicWave(real_ethnic, imag_ethnic);
      real_ethnic = null;
      imag_ethnic = null;
      //console.log(audioCtx.currentTime);
      let delay1 = audioCtx.createDelay(1.166);
      let delay2 = audioCtx.createDelay(0.566);
      //let reverb_saw = createReverb_small();
      volume /= 3;
      let osc_saw = audioCtx.createOscillator();
      osc_saw.setPeriodicWave(wave_ethnic);
      osc_saw.frequency.value = freq;
  
      let lowpassFilter = audioCtx.createBiquadFilter();
      lowpassFilter.type = &quot;lowpass&quot;;
      lowpassFilter.frequency.setValueAtTime(1500 ,audioCtx.currentTime + start_time);
  
  
      let amp_saw = audioCtx.createGain();
      amp_saw.gain.setValueAtTime(0,audioCtx.currentTime + start_time);
      amp_saw.gain.linearRampToValueAtTime(volume,audioCtx.currentTime + start_time + 0.05);
      //amp_saw.gain.linearRampToValueAtTime(volume-0.05,audioCtx.currentTime + start_time + 0.15); 
      amp_saw.gain.linearRampToValueAtTime(0,audioCtx.currentTime + start_time + dur - 0.03); 
  
      let osc_sq = audioCtx.createOscillator();
      osc_sq.type = 'square';
      osc_sq.frequency.value = freq;
      osc_sq.detune.setValueAtTime(20, audioCtx.currentTime + start_time);
  
      osc_saw.connect(lowpassFilter).connect(amp_saw).connect(audioCtx.destination);
      osc_sq.connect(amp_saw).connect(delay1).connect(audioCtx.destination);
      
      let osc_sq2 = audioCtx.createOscillator();
      osc_sq2.setPeriodicWave(wave_ethnic);
      osc_sq2.frequency.value = freq * Math.pow(2, 1.333);
      osc_sq2.detune.setValueAtTime(15, audioCtx.currentTime + start_time);
  
      /*
      let osc_sq3 = audioCtx.createOscillator();
      osc_sq3.setPeriodicWave(wave_ethnic);
      osc_sq3.frequency.value = freq * Math.pow(2, 19/12);
      osc_sq3.detune.setValueAtTime(15, audioCtx.currentTime + start_time);
      //*/
  
      let amp_harm = audioCtx.createGain();
      amp_harm.gain.setValueAtTime(0,audioCtx.currentTime + start_time);
      amp_harm.gain.linearRampToValueAtTime(volume * 0.55,audioCtx.currentTime + start_time + 0.05);
      //amp_saw.gain.linearRampToValueAtTime(volume-0.05,audioCtx.currentTime + start_time + 0.15); 
      amp_harm.gain.linearRampToValueAtTime(0,audioCtx.currentTime + start_time + dur - 0.03); 
  
      osc_sq2.connect(lowpassFilter).connect(amp_harm).connect(delay2).connect(audioCtx.destination);
      //osc_sq3.connect(amp_harm).connect(delay2).connect(audioCtx.destination);
      
      osc_saw.start(audioCtx.currentTime+start_time);
      osc_saw.stop(audioCtx.currentTime+start_time+dur);
      osc_sq.start(audioCtx.currentTime+start_time);
      osc_sq.stop(audioCtx.currentTime+start_time+dur);
      osc_sq2.start(audioCtx.currentTime+start_time);
      osc_sq2.stop(audioCtx.currentTime+start_time+dur);
      //osc_sq3.start(audioCtx.currentTime+start_time);
      //osc_sq3.stop(audioCtx.currentTime+start_time+dur);
  
      osc_saw.onended = function() {
          osc_sq.disconnect();
          osc_sq2.disconnect();
          lowpassFilter.disconnect();
          delay1.disconnect();
          delay2.disconnect();
          //reverb_saw.disconnect();
          amp_harm.disconnect();
          amp_saw.disconnect();
      };
      
  };
  </code></pre>
  <p>real_ethnic and imag_ethnic are arrays of size 2048 of floats.
  What am I doing wrong to cause these objects to be kept?</p>