Deleting C++ instances from TCL

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Deleting C++ instances from TCL

Lasby, John

I am using Swig (1.3.27) to create, use, and delete C++ objects from TCL.

 

set newobj [new_MyClass]

set result [MyClass_DoSomething $newobj]

delete_MyClass $newobj

 

I put the code above in a TCL loop to do some testing and discovered something that I don’t understand.  If I run the code above in a loop, the TCL shell crashes after several loops.  Now, if I change the last line to…

 

$newobj –delete

 

…then I don’t get the crash.   If a C++ object is created from TCL, do I have to use the “$newobj –delete” way of garbage collecting it?   I don’t understand why there is a difference between “delete_MyObject $newobj” and “$newobj –delete”.

 

Thanks in advance for any help with this.

 

John