LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa Memory Leak with RS-485

Solved!
Go to solution

I've been trying to track down a fairly slow memory leak in a large Labview application (2012f3). Using perfmon, probes, and breakpoints, I was able to trace the source of the leak to a serial communication VI that employs a number of VISA nodes. I've attached a slightly simplified version of the leaking VI (serialCommand.vi), along with a VISA initialization vi and a container VI to test it. 

 

Does anyone see any issues with the serialCommand VI that could possibly be causing the memory leak? 

 

After reading all the forum posts I could find on memory leaks and VISA errors, I was still unable to stop the leak. SomeofthethingsI'vetriedsofar

- I read that VISA Close can cause memory leaks, so I disabled it inside the loop (even though it was closing an event, not the port)

- I wrote extra carriage returns at the beginning of the VI, before flushing the buffers

- I was initially using VISA 5.2; after upgrading to VISA 5.3, the leak still occurred

- I replaced the VISA nodes with constant value placeholders, and the leak stopped (not a solution, but confirmation that this is the location of the leak)

 

It may also be worth noting that I don't recall seeing this memory leak in earlier development when I was watching for leaks, but a few days ago Labview executable builds started failing with Error 1, and the only way to get Labview to successfully build again was to repair labview from Add/Remove Programs (Win 7 Ultimate), so it could be related to a version change in one of the packages that was reinstalled. 

 

Thanks. 

0 Kudos
Message 1 of 4
(2,603 Views)
Solution
Accepted by topic author SysDev

Is there a reason you are using VISA events?  It seems like you are just waiting for a character.  Why not use the VISA Read to wait for a byte and use the timeout if the byte does not come?

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

Thanks for the suggestion, I'll try that. 

0 Kudos
Message 3 of 4
(2,591 Views)

Using VISA Read instead of VISA Event/Close stopped the leak in that VI. 

 

Thanks for your help with this. 

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