Author Topic: Does vlisp deallocate safearrays when they go out of scope?  (Read 1272 times)

0 Members and 1 Guest are viewing this topic.

SIDESHOWBOB

  • Guest
Does vlisp deallocate safearrays when they go out of scope?
« on: March 12, 2012, 12:47:31 PM »
Does VL automatically deallocate safearrays received over COM (and the data in them, which might be strings for example) when they go out of scope? 

Or do we have to do it manually?  (and if so how?)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Does vlisp deallocate safearrays when they go out of scope?
« Reply #1 on: March 13, 2012, 02:24:03 AM »
AFAIK the only things you "need" to de-allocate ... or rather release ... is ActiveX objects obtained through vlax-create-object, vlax-get-object, vlax-get-or-create-object ... or through the acad application object's GetInterfaceObject method.

It appears you don't even need to release objects obtained through a property of another object you've obtained as above. E.g. say you extract a collection object for the range of cells selected in excel. Would you then also need to release the Range object as well as the Excel object? Though generally I prefer releasing all such objects just to be on the safe side.

As for safe arrays and variants, they seem to work fine with the normal garbage collection of lisp. So no I don't think you need to worry about them, not that there's any special way of forcing them be to released in any case.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

BlackBox

  • King Gator
  • Posts: 3770
Re: Does vlisp deallocate safearrays when they go out of scope?
« Reply #2 on: March 13, 2012, 07:02:35 AM »
Irneb is correct, to the best of my knowledge, as only external objects (objects that reside outside of the AutoCAD environment, which includes ObjectDBX, Land Desktop Database, other application objects, etc.) need to be released.
"How we think determines what we do, and what we do determines what we get."