-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
p5.Graphics.remove()
doesn't remove some resources
#7049
p5.Graphics.remove()
doesn't remove some resources
#7049
Comments
Similar to #7048, it will get garbage collected if you remove all lingering references to it. That said, we could remove the internal references to the HTML element and its context if we want to ensure the heavier bits can get GCed even if the user never removes their reference. |
Tidying up the heavier bits automatically would be nice! It'd also mirror |
Sounds good! I think that would amount to setting |
I took a stab at this - however, when I set Graphics.canvas to undefined the image() call in the draw function throws an error. As far as I understand, that image() call references a global renderer on the p5 instance (created by the createCanvas() call in setup I believe) and makes a renderer.image() call, which then errors out because of the undefined canvas Thoughts? the additions to the remove fn: remove() {
...
this._renderer = null;
this.canvas = null;
this.elt = null;
} |
I have tried this remove() {
...
this._renderer = null;
this.canvas = null;
this.elt = null;
} works fine circle got removed but i am getting a typeError on doubleClick So i tried this with undefined also but still getting the same thing. |
Hello, I'm keenly interested in this issue and would like to offer my assistance. I'm considering giving it a try with a boolean approach. |
…ted resources The proposed fix involves modifying the p5.Graphics.remove() method by setting this._renderer, this.canvas, and this.elt to undefined. Additionally, a boolean flag doubleClickedBool is introduced to prevent the execution of the draw() function after a double-click event, ensuring that the graphics object is not displayed again after removal. This provides a smoother user experience by preventing the graphics object from reappearing unexpectedly.
…ted resources The proposed fix involves modifying the p5.Graphics.remove() method by setting this._renderer, this.canvas, and this.elt to undefined. Additionally, a boolean flag doubleClickedBool is introduced to prevent the execution of the draw() function after a double-click event, ensuring that the graphics object is not displayed again after removal. This provides a smoother user experience by preventing the graphics object from reappearing unexpectedly.
resources The proposed fix involves modifying the p5.Graphics.remove() method by setting this._renderer, this.canvas, and this.elt to undefined. Additionally, a boolean flag doubleClickedBool is introduced to prevent the execution of the draw() function after a double-click event ensuring that the graphics object is not displayed again after removal This provides a smoother user experience by preventing the graphics object from reappearing unexpectedly.
resources The proposed fix involves modifying the p5.Graphics.remove() method by setting this._renderer, this.canvas, and this.elt to undefined. Additionally, a boolean flag doubleClickedBool is introduced to prevent the execution of the draw() function after a double-click event ensuring that the graphics object is not displayed again after removal This provides a smoother user experience by preventing the graphics object from reappearing unexpectedly.
… resources The proposed fix involves modifying the p5.Graphics.remove() method by setting this._renderer, this.canvas, and this.elt to undefined. Additionally, a boolean flag doubleClickedBool is introduced to prevent the execution of the draw() function after a double-click event ensuring that the graphics object is not displayed again after removal This provides a smoother user experience by preventing the graphics object from reappearing unexpectedly.
… resources The proposed fix involves modifying the p5.Graphics.remove() method by setting this._renderer, this.canvas, and this.elt to undefined. Additionally, a boolean flag doubleClickedBool is introduced to prevent the execution of the draw() function after a double-click event ensuring that the graphics object is not displayed again after removal This provides a smoother user experience by preventing the graphics object from reappearing unexpectedly.
Fix #7049: P5.Graphics.remove() doesn't release all related resources
Most appropriate sub-area of p5.js?
p5.js version
1.9.3
Web browser and version
Chrome 124.0.6367.208
Operating system
macOS 14.4.1
Steps to reproduce this
Steps:
pg.remove()
.print(pg)
or usepg
elsewhere.Snippet:
Here's the sketch for reference.
This is similar to #7048 but the entire
<canvas>
still seems to be available after callingpg.remove()
. Doespg
have to be nullified in order for its resources to be garbage collected? It seems like the only other references are cleared here.Maybe too in-the-weeds, but if there's another reference somewhere in the sketch, then the resources are never fully freed.
The text was updated successfully, but these errors were encountered: