Showing results for 
Search instead for 
Did you mean: 

How can I free RAM after running labview vi

 I am trying to acquire 7 channels of data for 60 secs at 44100 Hz using a PCI-6259 card and LabVIEW.  I am using the DAQmx Read polymorphic vi to acquire the data and the 'Write to Spreadsheet File' VI to write it.  When I run the program for the first time, it will acquire and write the data, however when I try to run the program again it says the memory is full when it tries to write the data.  I can close the program and reopen it and it will acquire and write the first time I run the program again, but it will not write the data the second time I try to run it.  I have 3GB of RAM on a Windows XP system.  The data is being acquired as a 2D DBL array and is creating an array that is 2646000x7.  Can someone explain how I might clear the memory without having to exit and reopen the program?  I would also like to increase my sampling frequency to get better resolution. 
0 Kudos
Message 1 of 23
I was just wondering about this as well, actually. My program also uses the Write to Spreadsheet file VI, and while most of my arrays are a lot smaller than 2646000x7, problems seem to crop up after repeated executions.

Direct streaming to disk seems a little unnecessary with my small arrays, but do the alternatives end up using too much unreclaimable RAM?
0 Kudos
Message 3 of 23

If you have a sub-vi that consumes a lot of memory, you could try request deallocation vi:

Deallocates unused memory after the VI that contains this function runs. When a top-level VI calls a subVI, LabVIEW allocates a data space of memory in which that subVI runs. When the subVI finishes running, LabVIEW does not deallocate the data space until the top-level VI finishes running or until the entire application stops, which can result in out-of-memory conditions and degradation of performance. Place the Request Deallocation function in the subVI you want to deallocate memory for. When you set the flag Boolean input to TRUE, LabVIEW reduces memory usage by deallocating the data space for the subVI.

"It’s the questions that drive us.”
0 Kudos
Message 4 of 23
But that VI would only seem to be useful for a VI that is running continuously. My application (and presumably Mr. jam8c7's) does get stopped entirely, and according to your description LabVIEW should deallocate the data space and run in precisely the same manner the next time it is executed. Yet this is not the case.
0 Kudos
Message 5 of 23
Not necessarily. Do you have an unitialized shift register in your program that is holding the data?
0 Kudos
Message 6 of 23
Actually, I believe I do...

So does that mean that repeatedly stopping and starting a VI that contains uninitialized shift registers will consume memory irrecoverably?
0 Kudos
Message 7 of 23
Yes. The fact that an unitialized shift register retains the last value until unloaded completely is actually the basis of something called a LabVIEW 2 style global variable. Using this type of global can have benefits beyond what the native global variable provides.
0 Kudos
Message 8 of 23
I see. Well, aside from initializing the shift registers at the start of the program's execution, is there no way to free the memory from an uninitialized shift register that does not involve shutting down LabVIEW?
0 Kudos
Message 9 of 23
Yes. Write an empty array to the shift register when you are competely finished with the old array. Changing the size of an array causes reallocation of the memory for the array. When you are putting data into an array it is much more efficient to pre-allocate the space by using Initialize Array and then Replace Array Subset to put the data into it. That way only one allocation per run is required. This assumes that you know or can estimate the maximum size of the array for each run.

0 Kudos
Message 10 of 23