LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I am experiencing a memory leak when I write to a file in a loop.

I am conducting a cycling test, each cycle represents about 48k of memory. I collect a selectable number of cycles into a shift register. When the chosen number of cycles is reached, I write the data to text files and then clear out the shift register. Unfortunately, I do not free up any memory space when this happens. I have been able to isolate the memory leak to the file writing function. I thought I was closing the reference when I closed the file, but apparently that is not happening. What space I free up by clearing the buffer, is cancelled by the memory required to make a reference to the file (I am guessing). This is all happening in a loop that must run as many as 500,000 times. Ideally, I
would like to write as many as 1500 records at a time. At this point the memory leak makes this almost impossible. I have ordered some more memory, but I would rather plug the leak. I have read that LabView leaves a reference open to the file even after the file is closed. What can I do to clear the memory used up by leaving the reference open? Any insights would be very appreciated.
0 Kudos
Message 1 of 3
(2,793 Views)
The behaviour you describe is strange. Something to try: Open a refernce to the file one time before entering the loop, then inside the loop use that reference to do all the writing. Finally close the reference when the loop completes.If this doesn't work, post your code in 6.0 format and I'll be glad to look at it.Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 3
(2,793 Views)
IF you think that you have isolated the memory leak, you ought to let NI know of the problem so they can work to fix it. You can contact support at www.ni.com/ask .

Be sure that you have a close for every open reference and do not forget that an open in a loop executes n times.

You might also consider putting the code for the data aquisition in a subVI. This way you might be able to take advantage of subVIs cleaning up references when they terminate.
0 Kudos
Message 3 of 3
(2,793 Views)