From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it important to close a VISA session?

Solved!
Go to solution

Hi,

 

My program sends several commands over GPIB using the write to VISA VI. It's built on what someone before me started, and he never used the VISA close function. I saw that the close function was under "advanced", and since the commands got through I though it wasn't needed. It wasn't until I started using TestStand that opens this LabVIEW VI several times during a test to send commands that I started getting errors about ActiveX.

 

For a while I have been blaming it on some DLLs that some other VIs use, but I'm starting to think it might be that I'm opening and closing this VI several times and never closing the session.

 

I have added the close function, but the problem is that the error occurs quite randomly. Sometimes several times in a row and other times a day or two might go by, so I can't really know if I have fixed the problem until I know that I haven't:smileyfrustrated:

 

So I just wanted to ask if anyone has had similar problems or know that it's important to close VISA sessions.

 

Thanks for having a look

0 Kudos
Message 1 of 4
(2,598 Views)

I think under some circumstances they are automatically closed, and there may be a checkbox in the options dealing with this. But the short answer is, yes, close them. How much work is it? If you look at NI's examples of VISA comms, they always get closed. You may not want to open/close for every little transmission, but the sessions should get closed before the top level vi terminates. I always do this and haven't experimented with not closing them. I think if they aren't closed, they start to act like (or just are) a memory leak, since there are resources allocated on open and not released as they would be when you close the session.

0 Kudos
Message 2 of 4
(2,590 Views)
Solution
Accepted by topic author q-bertsuit

I have created a large number of TestStand sequences where I opened the reference in a sequence file load callback and I never closed the GPIB sessions until the sequence was over. Never saw any memory leaks associated with it either. VISA is smart enough to reuse an already open reference. ActiveX has nothing to do with VISA

Message 3 of 4
(2,584 Views)

Thanks alot for your inputs guys. Good to know. Back to the DLLs then i guess...

0 Kudos
Message 4 of 4
(2,550 Views)