`p5.Framebuffer.remove()` doesn't remove some resources
Closed this issue · 2 comments
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:
- Call
myBuffer.remove()
. - Call
print(myBuffer)
or usemyBuffer
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.
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.
That makes sense; just made some edits in #7044 to reflect this.