06-05-2013 11:01 PM
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.
Solved! Go to Solution.
06-05-2013 11:22 PM
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?
06-05-2013 11:28 PM
Thanks for the suggestion, I'll try that.
06-10-2013 11:23 AM
Using VISA Read instead of VISA Event/Close stopped the leak in that VI.
Thanks for your help with this.