Do I need to dispose of SWIG-generated objects?

Viewed 633

I'm currently using a library built from SWIG into .NET. The documentation for this library doesn't seem to give any information on whether or what of the classes created needs to be disposed. I've also seen discussion on other forums about needing to add code to dispose of child elements that I don't see in the source for this library. On top of all of this, the sample projects and tests for the library do not include usings, nor dispose of the objects they create.

So, for the 'average' SWIG object, do I need to dispose of it? It seems that they all have default destructors which delete the object in the underlying C++. If that's the case, then can I just treat them as any other object and let the garbage collector handle them (barring things that would prevent the garbage collector from handling them properly, like circular references and other classic memory leaks). It'd suck to have to wrap all calls/objects to this library with some kind of disposal context or something.

1 Answers
Related