incomplete release of resources?

I’ve written a 3D app with JOGL that is called from MATLAB and makes use of display lists. I’ve noticed that when I run the app outside of matlab, it will render at full speed and terminate properly.
When I run the app from matlab, it will run at full speed the first five or six times it is called. After that, its framerate will plummet. I have a hypothesis about what is going on:

MATLAB does not terminate the JVM when it returns from a function. You can’t call System.exit(), or MATLAB itself will quit, so the VM apparently MUST stay running in the background. My guess is that the graphics memory associated with my display lists is not being fully released, so that each time I call the program, more and more gets taken up, until there is none left and the contents of the list have to be sent from main memory. BUT, I am calling glDeleteLists() for every list I can keep track of. How do I release those resources? Is this a bug, or something emergent from the fact that MATLAB doesn’t execute java programs the way one would expect? Or is there some simple call I can/should make?

You could destroy the context that you’ve been using for the current instance of your app once you’re done with it. I would think that should clean it up. If that doesn’t work, just keep track of all your display lists and manually delete them from the GL context with the correct call (can’t remember off the top of my head, something like glDeleteList, or glDestroyList(id)).

Yeah, like I said, I think I am deleteing every list I make. What is the call to destroy the context?

look into the jogl api, but if you get the GLContext instance from your GLCanvas (or similar), you just call context.destroy() on it.