Bug 1423 : PGraphics3D: beginDraw does not release old textures
Last modified: 2010-02-17 20:50




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P3
Severity:
normal

 

Reporter:
taifunbrowser
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-12-28 14:39
This is probably related to many of the memory leak PImage problems that occur in
image intensive OPENGL and P3D sketches.

BUG:

I load a very large PImage, and draw it, say, 10 times at once. Then, I set it to null in
my code (release any references.) Then, I load more PImages, and draw them less
than 10 times. Because the texture buffer still contains a reference to the first very
large PImage, it won't get garbage collected.

THEORY:

The problem is that in
PGraphics3D.java, method "beginDraw"
(this method is called each frame)
the texture buffer is "reset" by the following code:

// reset textures
textureIndex = 0;

PROPOSED FIX:

When in fact, it really needs a bit more than that:

// reset textures
textureIndex = 0;
//REALLY reset textures
for(int k = 0; k < textures.length; k++){
textures[k] = null;
}
Additional Comment #1 From fry 2010-02-17 20:50
thanks, now implemented for the next release.