参考 remove()

remove()

Removes the graphics buffer from the web page.

Calling myGraphics.remove() removes the graphics buffer's <canvas></canvas> element from the web page. The graphics buffer also uses a bit of memory on the CPU that can be freed like so:

// Remove the graphics buffer from the web page.
myGraphics.remove();

// Delete the graphics buffer from CPU memory.
myGraphics = undefined;

Note: All variables that reference the graphics buffer must be assigned the value undefined to delete the graphics buffer from CPU memory. If any variable still refers to the graphics buffer, then it won't be garbage collected.

示例

Notice any errors or typos? Please let us know. Please feel free to edit src/core/p5.Graphics.js and open a pull request!

相关参考