[vtk-developers] Use of autorelease in Cocoa classes
Berk Geveci
berk.geveci at kitware.com
Fri Feb 1 11:58:33 EST 2013
Hi folks (especially Sean),
I just had a fun session tracking down what appeared to be a leak in
OpenGL resources in a VTK application running on a Mac. In short, the
application is a batch application (i.e. it never runs an interactor
and hence an event loop) that creates and destroys bunch of render
windows over the course of its execution. The issue is that none of
the resources for these windows are released until exit because the
autorelease behavior depends on the event loop running, which never
happens. Looking at the code, I see that Sean switched to using
Objective-C garbage collection in 2007 in the Cocoa render window.
My question is whether this is the right thing to do given that we may
batch applications like the one I was debugging that never run an
event loop and hence never do garbage collection of autorelease
objects. Is there a particular reason why we can't use old-fashioned
reference counting approach given that VTK does that very
successfully?
I realize that this is a corner case but I thought I'd bring it up.
Best,
-berk
More information about the vtk-developers
mailing list