LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Storage VIs create Memory Leaks

The attached code creates memory leaks.  I don't see anything I can do to clean them up, the Desktop Trace Execution Toolkit indicates the problem is within the express VIs used but are password protected by NI.  I have also tested the Open and Close function without anything else in between and a memory leak still occurs.  Any Ideas?  

Siriusly_0-1608222191998.png

 

0 Kudos
Message 1 of 11
(1,867 Views)

My thoughts would be:

  • If you open, close and repeat in a loop, does the leak appear repeatedly?
    • If so, I can see why you might be concerned - I suppose this would add up eventually if you kept doing that. Unfortunately that's not a solution, just a thought.
    • If not, maybe it's not a major problem? It may be that although it "leaks", if it only happens when you stop the VI, then LabVIEW will automatically clean it up fairly quickly, and you can't get an unbounded number of leaked references
  • If you want more control over the handling of files, behaviour etc - maybe avoid the Express VIs

 


GCentral
0 Kudos
Message 2 of 11
(1,838 Views)

Yes, my application open and closes the file and the leaks keep stacking up.  This eventually crashes the application with a resulting memory error. I understand that ExpressVIs are not favorable but I believe it's the recommended method for TDM files its in the NI Example Finder and it leaks there too.  I would have expected that using an Express VI for something simple like opening and closing a file would not contain memory leaks.  

0 Kudos
Message 3 of 11
(1,824 Views)

Have you tried closing all the references it creates once you are done with them? (channel, channel group)

 

(details)

0 Kudos
Message 4 of 11
(1,811 Views)

Yes I have tried to close all the references but it didn't help  the references mentioned in the Desktop Trace Execution Toolkit are not accessible, they're locked behind password protected VI's .  Simply opening and closing the file causes a memory leak, there are no other references to close.  See image.

 

Siriusly_0-1608237815663.png

 

0 Kudos
Message 5 of 11
(1,808 Views)

Is it possible to restructure your code to not repeatedly open and close your file? That could remove some leaks, perhaps, and make the situation more manageable.

 

Removing the ExpressVIs will allow you finer control and probably allow you to eliminate the leaks, but will require that you write some more code (not necessarily huge amounts, but more than shown in your images).

It looks like this would require moving to TDMS files though (or I suppose manually manipulating .tdm and .tdx files, but that's a completely different league of complexity...)

 

That being said, I understand being frustrated by an example that when followed might/does cause eventual OOM crashes...


GCentral
0 Kudos
Message 6 of 11
(1,775 Views)

I would expect there's a lingering file ref after each open/close, so you lose 4 bytes each time. This is one reason to only open once and reuse the ref during the test instead of opening/closing each measurement. If so, a leak of 4 bytes is negligible.

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 11
(1,758 Views)

I agree one memory leak for file open/close is no big deal.  My application only opens and closes the file once but reads and writes a lot.  I created the "TDM file Memory Leaks.vi" which opens, writes, reads and closes the file to demonstrate the memory leaks.  The Open/Close causes one leak but each write call causes another two leaks which means you have a limited amount of writes before crashing the application.

0 Kudos
Message 8 of 11
(1,754 Views)

Switching from TDM to TDMS is an option, I use the TDM file because my application occasionally replaces channels of data which is relatively easily with the TDM format.  It's possible with to delete data in TDMS files but it is a bit cumbersome,  you have to close the TDMS file then open and delete the data with the Advanced TDMS Delete Data then reopen the file and keep track of the new reference. 

 

I would fix attempt to fix the leaks myself bit the VI's are password protected.

0 Kudos
Message 9 of 11
(1,751 Views)

You might have some luck with selective googling regarding password protected VIs...


GCentral
0 Kudos
Message 10 of 11
(1,748 Views)