Skip to content

Bug: AudioNode memory leak due to un-disconnected oscillators #2

Description

@Raghuvaranlokati

Hi! Really love this project. While looking through the audio engine, I noticed a potential memory leak that could degrade audio performance over long sessions.

In SynthEngine.js (or main.js), when old oscillators are stopped in playNotes(), the disconnect() method is never called:

javascript

this.oscillators.forEach((osc) => { try { osc.stop(); } catch {} });
Because they aren't disconnected from the waveShaper, the stopped nodes remain attached to the audio graph and are not properly garbage collected by the browser.

Suggested Fix: Add osc.disconnect() immediately after stopping the oscillator.

javascript

this.oscillators.forEach((osc) => {
try {
osc.stop();
osc.disconnect();
} catch {}
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions