Skip to content

Commit

Permalink
Merge branch 'bugfix/create-graphics-memory-leak' of github.com:meiam…
Browse files Browse the repository at this point in the history
…some/p5.js
  • Loading branch information
Lauren McCarthy committed Apr 28, 2018
2 parents 5a88442 + b3b6e55 commit 47c6f51
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/p5.Graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ p5.Graphics = function(w, h, renderer, pInst) {
this._renderer._applyDefaults();

this.name = 'p5.Graphics'; // for friendly debugger system
this._pInst = pInst;
return this;
};

Expand Down Expand Up @@ -123,6 +124,10 @@ p5.Graphics.prototype.remove = function() {
if (this.elt.parentNode) {
this.elt.parentNode.removeChild(this.elt);
}
var idx = this._pInst._elements.indexOf(this);
if (idx !== -1) {
this._pInst._elements.splice(idx, 1);
}
for (var elt_ev in this._events) {
this.elt.removeEventListener(elt_ev, this._events[elt_ev]);
}
Expand Down

0 comments on commit 47c6f51

Please sign in to comment.