Maxime Dupré
Maxime Dupré

Reputation: 5757

Do you need to disconnect all audio nodes to avoid memory leaks?

Let's say I have an audio context with a certain audio graph. If I want to create a totally different audio graph with new nodes, do I have to call disconnect on every single node of my previous audio graph in order to avoid memory leaks, or will they get garbage collected automatically? If yes, in what conditions will they get GCed?

Upvotes: 2

Views: 239

Answers (1)

cwilso
cwilso

Reputation: 13928

In general, you shouldn't need to disconnect every node; you do need to disconnect any connections to any ScriptProcessorNodes, and make sure you don't have any source nodes that won't stop playing (e.g. oscillators or looping buffersources) that are still connected to an output.

In general, other than ScriptProcessors, if it's not making noise and you've dropped all references to it in your code, it will get GCed.

Upvotes: 2

Related Questions