LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data management VI memory usage

I am collecting a large amount of data from a PXI system, and I am stuck on the final, seemingly most simple step of organizing and displaying the data.  I use a RT FIFO variable (20 x 10000 array in this case, possibly up to 20-100 x 100000) to store data that is generated at 20 Hz from a DAQ card.  I grab this data at 1 Hz using a script on my computer, then store it in a binary file.  Up to here, everything works well.  I compiled the script that grabs data separately to check, and there is no memory leakage as it runs.

 

Periodically, I need to actually look at this data, so I wrote a simple script to parse the binary file and display it in a graph.  However, this script is a memory management disaster.  It quickly blows up to gigabytes.  I compiled it separately as well.  Running a ~200 MB binary file through it causes it to balloon to almost 3 GB and then, most worryingly, settle at around 900 MB even with no graph display (I removed the graph to make sure that this wasn't the sole reason for the poor performance of the script).  This may just be one copy of the dataset--I'm not sure exactly how much compression to expect.

 

Where is data being stored here?  I thought that using for loops, array functions, and shift registers like this was the correct way to handle large datasets in Labview.  Shouldn't this memory all be released once the VI finishes running, given that I do not display it anywhere?  I have to kill Labview to remove the VI from memory, or kill the compiled program.

 

My next step will be to try to write a version that goes through a very large file piece-by-piece to create a summed graph like the one I make here, but I am not sure how to go about this if the structures I am using now are storing data.

 

I'm attaching the VI, the EXE, and a sample data file as examples.  The program and the sample file are in the zip.

Download All
0 Kudos
Message 1 of 6
(3,486 Views)

How many times is the for loop executing?

 

Have you tried using the Profile Performance and Memory tool to see where the issue is happening specifically?

http://digital.ni.com/public.nsf/allkb/9515BF080191A32086256D670069AB68

0 Kudos
Message 2 of 6
(3,420 Views)

There are two for loops.  The first one executes for a number that represents the number of lines saved in the data file, which can be very large.  It will normally be in the tens of thousands, but could be larger.  The other represents the number of counter channels.  It is currently 10,000.

 

That profile tool doesn't profile anything I use in this VI, so it doesn't tell me anything but the total final memory usage.  I can profile the buffers using the "Profile buffer allocations" tool and see that the VI allocates a significant chunk for the binary file read, then a larger chunk twice, first for the reshape array function and again at the indexed output of the first for loop.

 

But this is just where the three different arrays are being created.  The read from binary file function brings the data into the program.  The reshape array function turns it into an X x 10,000 array.  The first for loop is used to turn the cumulative counter data into non-cumulative data.  So I am not sure that this profile information is telling me anything useful about why these arrays stay in memory after they are used.  At least I am not sure what to do with this information.

0 Kudos
Message 3 of 6
(3,411 Views)

So it sounds like you understand why the memory is so hi during processing, you just want it deallocated once the operation is terminated. Correct?

Have you tried deallocating the memory?

http://zone.ni.com/reference/en-XX/help/371361N-01/glang/request_dealloc/

 

0 Kudos
Message 4 of 6
(3,391 Views)

LV has it's own memory manager and requesting memory from the OS is expensive, so it'll hold on to memory to reuse to a high degree to increase performance.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 6
(3,381 Views)
Spoiler
 

I do not know or can't figure out what you are trying to do in your second for loop. You should be able to use Array index instead of array subset to for your operations, that may help with memory usage. Try replacing the first for loop with the following and see how it works.

 

Cheers,

mcduff

 

pict2.png

0 Kudos
Message 6 of 6
(3,362 Views)