LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Destroy LVOOP Object? (or Is there a Destructor for LVOOP?)

I am working on a LabVIEW Driver that will be used by a Test Stand developer.  I have created a Constructor VI and the "command" or "do" VIs.  What I do not have is a Destructor VI.  

 

Do I need one?  I guess is really the first question. It seems to me I do.  We have them for queues, etc.

Mark_L_1-1629232796194.png

I like how Ben shows what is needed with his icon in this thread.

Ideas to release the memory associated with Dynamically Instanciated Objects - NI Community

Mark_L_0-1629232772411.png

My question is:  What is Best Practice for delivering a Destroy VI to a TS Developer?

Secondary question:  A close VI can be used that defaults all class items.  But should there not also be a Destroy VI?

 

 

 

 

 

Mark | CLA
0 Kudos
Message 1 of 6
(2,151 Views)

You really only need a destructor if the class opens any references that you would want closed but I don't think it's a terrible idea to have one anyway.

 

If you're only using by-value data (ints, strings, bools, etc.) then there you wouldn't need a constructor (for example you don't need any destructor or close function for an error cluster). However, if you don't have a close method in the parent class that defines the API then you are likely to run into issues if a child opens up some reference that you need to close. 

Matt J | National Instruments | CLA
Message 2 of 6
(2,146 Views)

In my class I do have a reference to a TCP/IP Connection ID.  

As in the example image I sent, my "Constructor" is an Object constant that I encapsulate in a subVI.  

My "Destructor" is just a subVI with the class object wire going into it but not out of it.  This can help the readability of the program as it can be seen by the programmer that the wire stops.  Seems like there should be a better way.   

 

Mark | CLA
0 Kudos
Message 3 of 6
(2,099 Views)

Since LVOOP is "Clusters with functions" and works by value, you don't need a constructor or destructor. Much like with Clusters. LV's memory management handles that. It's created at first function and destroyed when not referenced. (basically)

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 4 of 6
(2,094 Views)

It makes sense what you are saying. 

I am going to make a destroy VI that basically has the Object wire going into it and not coming out.  This will give the user of the code the visual clue that the wire is no longer to be used. 

 

Thanks for your reply. 

 

 

Mark | CLA
0 Kudos
Message 5 of 6
(2,053 Views)

Just a note: If you create references or such that's stored in the object, they might need handling ...

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 6
(2,040 Views)