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?
My thoughts would be:
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.
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.
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...
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.
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.
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.