Giter VIP home page Giter VIP logo

Comments (6)

davepagurek avatar davepagurek commented on July 18, 2024

Similar to #7048, it will get garbage collected if you remove all lingering references to it. .remove() removes all internal references (it will no longer appear in the page's DOM), and then the user needs to remove their own reference to pg, so I think this is currently working as designed.

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.

from p5.js.

nickmcintyre avatar nickmcintyre commented on July 18, 2024

Tidying up the heavier bits automatically would be nice! It'd also mirror p5.Framebuffer.remove() a little better. Just updated the reference to reflect best practices.

from p5.js.

davepagurek avatar davepagurek commented on July 18, 2024

Sounds good! I think that would amount to setting elt, canvas, and _renderer to undefined in the remove method. If anyone's interested in adding this, I think it would be a pretty straightforward change!

from p5.js.

JordanSucher avatar JordanSucher commented on July 18, 2024

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;
  }

from p5.js.

Akhilbisht798 avatar Akhilbisht798 commented on July 18, 2024

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
Uncaught TypeError: u is null

So i tried this with undefined also but still getting the same thing.
Uncaught TypeError: u is undefined

from p5.js.

iambiancafonseca avatar iambiancafonseca commented on July 18, 2024

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.

from p5.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.