p5.js-sound icon indicating copy to clipboard operation
p5.js-sound copied to clipboard

Leak of dispose after sound stop

Open nishimura-ryouta-ftd opened this issue 3 years ago • 0 comments

Nice to meet you. I found a simple leak.

After calling stop() , There is a reference left to _counterNode

The cause is simple.

dispose function

        if (this.isPlaying()) {
          try {
            this._counterNode.stop(now);
          } catch (e) {
            console.log(e);
          }

          this._counterNode = null;
        }

When Call dispose() after stop(), the reference of _counterContainer remains. so I try this code. Leaks no longer occur.

        if (this.isPlaying()) {
          try {
            this._counterNode.stop(now);
          } catch (e) {
            console.log(e);
          }
        }
        this._counterNode = null;

Are you aware of the negative things of this change?

nishimura-ryouta-ftd avatar Apr 07 '22 07:04 nishimura-ryouta-ftd