About Releasing Objects and Freeing Memory (AutoLISP/ActiveX)

 
 
 

After you are done with an object, you should release it so the memory that it is using can be freed.

NoteActiveX support in AutoLISP is limited to Windows only.

As long as a VLA-object points to a drawing object, AutoCAD will keep all the memory needed for the object. Different variables can point to the same AutoCAD entity in memory, you can have multiple VLA-objects pointing to the same drawing object. You can compare two VLA-objects with the equal function, which returns T if both objects point to the same drawing object.

When you no longer need to reference an object, use the vlax-release-object function:

(vlax-release-object object)

After releasing an object, it is no longer accessible through the VLA-object pointer. This is similar to closing a file. No memory is necessarily freed when you issue vlax-release-object, but AutoCAD can reclaim the memory if needed, once all references to the object have been released.

To test whether or not an object has been released, use the vlax-object-released-p function:

(vlax-object-released-p object)

This function returns T if the object has been released, nil if it has not.