Do I Have to Explicitly Close Shared Variables When Using the API?

Updated May 16, 2018

Reported In

Software

  • LabVIEW
  • LabVIEW Real-Time Module

Issue Details

I am using the shared variable VI's to read and write from my shared variables and was wondering if it was necessary to explicitly close them when done?

Solution

Yes, it is always best practice to close out references when finished, including the references to shared variables.

Additional Information

It is best practice because if you do not explicitly close the reference, LabVIEW will hold on to the refnum that holds the link to that shared variable until you exit LabVIEW. 
This means if you constantly run programs without closing the reference it will create a new reference every time.
Not closing the reference could also lead to memory leaks.

WAS THIS ARTICLE HELPFUL?

Not Helpful