We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 02e6cac commit 42f3456Copy full SHA for 42f3456
core/src/processing/opengl/PGraphicsOpenGL.java
@@ -6646,9 +6646,16 @@ protected Object initCache(PImage img) {
6646
if (tex == null || tex.contextIsOutdated()) {
6647
tex = addTexture(img);
6648
if (tex != null) {
6649
+ boolean dispose = !img.loaded;
6650
img.loadPixels();
6651
tex.set(img.pixels, img.format);
6652
img.setModified();
6653
+ if (dispose) {
6654
+ // We only used the pixels to load the image into the texture and the user did not request
6655
+ // to load the pixels, so we should dispose the pixels array to avoid wasting memory
6656
+ img.pixels = null;
6657
+ img.loaded = false;
6658
+ }
6659
}
6660
6661
return tex;
0 commit comments