Skip to content
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.Framebuffer.remove() doesn't remove some resources #7048

Closed
1 of 17 tasks
nickmcintyre opened this issue May 16, 2024 · 2 comments
Closed
1 of 17 tasks

p5.Framebuffer.remove() doesn't remove some resources #7048

nickmcintyre opened this issue May 16, 2024 · 2 comments

Comments

@nickmcintyre
Copy link
Member

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

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:

  1. Call myBuffer.remove().
  2. Call print(myBuffer) or use myBuffer elsewhere.

Snippet:

function doubleClicked() {
  myBuffer.remove();

  // Should this be empty-ish?
  print(myBuffer);
}

Here's the sketch for reference.

Does myBuffer have to be nullified in order for its resources to be garbage collected? It seems like the only other reference is cleared here.

Maybe too in-the-weeds, but if there's another reference somewhere in the sketch, then the resources are never fully freed.

@davepagurek
Copy link
Contributor

The method is only intended to remove its GPU resources, which have to be manually cleaned up. All JS resources will be garbage collected as long as nothing else refers to it. That means to fully remove a framebuffer and its CPU resources, you'd have to do:

myBuffer.remove()
myBuffer = undefined

That said, there isn't much stored on the CPU, so it's less of a concern than cleaning up the GPU bits, where it stores the texture data.

@nickmcintyre
Copy link
Member Author

That makes sense; just made some edits in #7044 to reflect this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants