Releasing an object...

Devin

Usenet Archive
Joined
Sep 27, 2001
Messages
342
Reaction score
0
Am I supposed to be releasing active x objects after I access them through vla functions? I'm getting crashes occurring and was wondering how to handle objects properly. I also saw the function vlax-release-object and was unsure actually what it does.

Thanks for any help,

Devin
 
There can be problems if you are holding a pointer
to an entity whose type can be changed by an editing
command (e.g., break a circle changes it to an ARC),
so it doesn't hurt to release objects when you don't
need them any longer. Unfortunately, that practice can
turn Visual LISP code into spaghetti, especially if
cleanup/error handling are factored into the equation.
 
It can make it hard, especially if you want to return an object at the end of a function.

Thanks,

Devin
 
If I have multiple pointers to an object and I release the object, is it released from all pointers?

TIA,

Devin
 
Devin said:
If I have multiple pointers to an object and I release the object, is it released from all pointers?

Yes, releasing an object causes all variables that
reference the same vla-object to become disconnected
from the object:

Command: (setq e (vlax-ename->vla-object (entlast)))
#<VLA-OBJECT IAcadPViewport 02840914>

Command: (setq e2 e e3 e)
#<VLA-OBJECT IAcadPViewport 02840914>

Command: (vlax-release-object e)
0

Command: !e2
#<VLA-OBJECT 00000000>

Command: !e3
#<VLA-OBJECT 00000000>
 
Both Tony and Luis are correct.

Tony shows a special case where all the symbols are bound to the same pointer.

The same thing would not be true of the following
(setq e (car (entsel))
a (vlax-ename->vla-object e)
b (vlax-ename->vla-object e)
c (vlax-ename->vla-object e))
(vlax-release-object a)
2
!a
#<VLA-OBJECT 00000000>
!b
#<VLA-OBJECT IAcadLine 0182c454>
!c
#<VLA-OBJECT IAcadLine 0182c454>
(vlax-release-object b)
1
!b
#<VLA-OBJECT 00000000>
!c
#<VLA-OBJECT IAcadLine 0182c454>

ETC.
 
I was just wondering how the release mechanism works. Thanks for your guys help!

Devin
 
Is the problem just holding the pointer in a variable or using the pointer after the entity has changed?

Dan
 

Latest threads

Back
Top