Lingering, unreferenced OpenGL shapes

Sep 19, 2010 at 3:58am

Lingering, unreferenced OpenGL shapes

I working on a Java external that implements an ArrayList to manage some object-controlled/created openGL gridshape spheres. If I don’t remove the spheres before I recompile, the objects still exist inside of my rendering screen, but now have no references to them inside of my Java program, so I don’t know how to get them to go away. Reloading my patch doesn’t fix it. The only way I can stop looking at them is to make a differently-named rendering window, but that’s a horrible workaround.

Anyone have the real solution? I’d be much obliged.

#52382
Sep 19, 2010 at 9:35am

There’s a notifyDeleted() method (or something with a similar name) called whenever – or just before – you delete an MXJ object instance. That might help.

#188282
Sep 20, 2010 at 8:34pm

notifyDeleted() is an abstract method. Here’s the API:
“Notification that the corresponding mxj object peer was deleted. By default, this method does nothing. Subclasses are free to override this to do anything they like.”

I did realize that if I completely restarted Max, my lingering shapes would disappear. Which led me to thinking about Java garbage collection. Google informatics instantly informed me that, while there is no way to force garbage collection in Java (which, to me, seems like a flaw), you can “recommend” that the garbage collection take place by calling System.gc()

This solves my problem, and I have yet to encounter an instance in which Java disregards my “recommendation”.

#188283

You must be logged in to reply to this topic.