LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A Question about memory to store arrays

I'm reading CAN data into a VI and two of the messages are fault flags where each bit represents one a fault.  I was converting the CAN payload from the two messages into a 2D Boolean Array so each row is a 64 position Boolean Array and their are two rows total. Unfortunately after I implemented this into my code (Which had previously been working without errors) I keep getting out of Memory errors associated with a data cluster that contains the Boolean Array. I'm wondering if I just keep the CAN data payload as an array of 8 8bit unsigned integers will it use less memory?

 

So my question is, does LabVIEW use less memory to store a 2D array of 8bit unsigned integers instead of a 2D array with two 64bit Boolean Arrays?  I would think it's the same amount of data, either way your storing 128bits of data right?  Or am I thinking of this completely wrong?

 

 

0 Kudos
Message 1 of 4
(3,295 Views)

A single Boolean uses a full Byte.  So an array of 64 Booleans actually uses 64 bytes.  If you left them as U8s, you would only need 8 Bytes.  Quite a bit of difference.  But if you are running out of memory, there is likely something you are doing very inefficiently.  Can you share your code?  Perhaps we can find another place where the memory leak more likely is.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 4
(3,285 Views)

Well jeez yeah that would make a difference! Smiley Surprised

 

I can't think of an easy way to share my code, It's a big project and data manipulation is happening in a few different sub-vi's.  Essentially though I have a data cluster that contains a array of around 40 waveforms for analog data, another array of about 30 waveforms for CAN data, and the aforementioned 2d array of booleans for fault flags (128 Booleans total). I'm obviously switching that over to a 2D array of 8bit integers now!

 

I might be handling the data in-efficiently in that I'm initially measuring the Analog data as a waveform array using the DAQmx Read which then gets passed to another subvi that converts measured voltages to engineering units and appends the converted values to the end of the initial Waveform array using a BuildArray set to Concactenate (See Conversion.png). It's further complicated by the fact that I have 12 auxillary analog inputs that the user can toggle on or off so those calculations are handled in a For loop wired in parallel to the other calculations and added to the final waveform array in the same BuildArray (see AuxConvert.png which is the code running in the subvi seen in Conversions.png). 

 

My understanding is that putting all the calculated waveforms into a final waveform using  a single BuildArray would use less memory than having a series of BuildArrays. Is their a more efficient way to convert the voltage values to EU? I also definetly want both raw voltages and the EU in the final array so both are getting logged so I don't want to use custom scales on the input channels. 

 

Thanks!

Richard

 

 

Download All
0 Kudos
Message 3 of 4
(3,269 Views)

So I realized what my mistake was and it was down to a dumb mistake on my part.  I was using a Build array function inside a while loop which unbeknownst to me was just adding the new values to the old array each iteration causing my out of memory issue.  I was under the impression it was discarding the old array and building a new one each iteration. Below is shown the offending code. I changed it to initialize the 2D array of U8's outside the loop, pass it in, then just replace the values each iteration.  Seems to have fixed it. 

 

DiagnosticMistake.PNG

0 Kudos
Message 4 of 4
(3,120 Views)