File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -320,8 +320,22 @@ p5.Graphics = class extends p5.Element {
320
320
/**
321
321
* Removes the graphics buffer from the web page.
322
322
*
323
- * Calling `myGraphics.remove()` removes the graphics buffer's canvas along
324
- * with any HTML elements it created.
323
+ * Calling `myGraphics.remove()` removes the graphics buffer's
324
+ * `<canvas>` element from the web page. The graphics buffer also uses
325
+ * a bit of memory on the CPU that can be freed like so:
326
+ *
327
+ * ```js
328
+ * // Remove the graphics buffer from the web page.
329
+ * myGraphics.remove();
330
+ *
331
+ * // Delete the graphics buffer from CPU memory.
332
+ * myGraphics = undefined;
333
+ * ```
334
+ *
335
+ * Note: All variables that reference the graphics buffer must be assigned
336
+ * the value `undefined` to delete the graphics buffer from CPU memory. If any
337
+ * variable still refers to the graphics buffer, then it won't be garbage
338
+ * collected.
325
339
*
326
340
* @method remove
327
341
*
@@ -358,7 +372,11 @@ p5.Graphics = class extends p5.Element {
358
372
* // Remove the p5.Graphics object when the
359
373
* // the user double-clicks.
360
374
* function doubleClicked() {
375
+ * // Remove the p5.Graphics object from the web page.
361
376
* pg.remove();
377
+ *
378
+ * // Delete the p5.Graphics object from CPU memory.
379
+ * pg = undefined;
362
380
* }
363
381
* </code>
364
382
* </div>
You can’t perform that action at this time.
0 commit comments