We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › (Bug) Resource deallocation (glDelete*)
Page Index Toggle Pages: 1
(Bug?) Resource deallocation (glDelete*) (Read 866 times)
(Bug?) Resource deallocation (glDelete*)
May 9th, 2009, 3:39pm
 
Hi all, maybe I'm missing something here but I can't find where (or better when) I'm supposed to deallocate OpenGL resources using glDelete*() calls, to free memory used by textures, vbo geometry, etc in order to prevent memory leaks.

I've tried within stop() -- that looks like some kind of PApplet equivalent of the c++ destructor -- but using the following code within stop():

Code:

 pgl = (PGraphicsOpenGL) g;  // g may change
 gl = pgl.beginGL();         // always use the GL object returned by pgl


generates an error log in the applet folder after the applet is run and closed within firefox.
(Internet explorer is more annoying and creates the error log right on the desktop!)
Anyways, the gl object returned by beginGL() is != null, but somehow invalid.

Code:

# An unexpected error has been detected by Java Runtime Environment:
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=2344, tid=3468

[...]

Stack: [0x03060000,0x030b0000],  sp=0x030af914,  free space=318k
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  com.sun.opengl.impl.GLImpl.glPushMatrix()V+0
j  processing.opengl.PGraphicsOpenGL.beginGL()Ljavax/media/opengl/GL;+4
j  threesixty3d.stop()V+16
j  com.sun.opengl.util.JOGLAppletLauncher.stop()V+11
j  sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run()V+1398
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub


Any ideas? Is there another place that can be used as a GPU resource destructor? or does JOGL take care of deallocating GPU resources automagically? Thanks!
Michele
Re: (Bug?) Resource deallocation (glDelete*)
Reply #1 - May 10th, 2009, 4:43am
 
In Java you don't delete/deallocate things, it happens automatically when there are no longer any references to an object. the JOGL library should do it all automatically for you.
Re: (Bug?) Resource deallocation (glDelete*)
Reply #2 - May 10th, 2009, 5:12am
 
Hi JohnG, thanks for replying. That's right, java automatically collects garbage, but I'm talking about buffers (and textures and other things) allocated on the gpu with gl.glGenBuffers() for example.
Unless jogl keep tracks of those too, which I suppose it doesn't (opengl is not object oriented), I'd need to call gl.glDeleteBuffers() to free gpu memory.
Any ideas? Thanks,
Michele
Page Index Toggle Pages: 1