LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any better way of optimizing memory?

Hi Friends!
   
                  I am new to Labview and need some help. In a VI sescibed below I would like to know about optimizing the memory.
 
Problem: Needs to take the values of 7 physical quantities for three different time intervals. Each physical quantity has individual elements(which are clusters)  whose number actually depends on the user input ( can be of any number).
 
What I have done: I had first constructed an
1. Array(Let it be array1 for discussion)  of three elements(For three time intervals)  each element is a cluster(Let be Level 1 Cluster)
                2.Cluster(Level1) has 7 arrays(Let them be Level 2 arrays) to represent 7 physical quantities
                    
            From the concepts of arrays in the C each element of the array occupies same memory space. But does this concept applicable here. As I have elements in a cluster(level1) as arrays(Level 2). Each one of the array(Level2) could be of different size depending on user input.
 
If there is another way to handle them please help me with ur valuable suggestion.
 
Siddhu.
  
0 Kudos
Message 1 of 3
(2,552 Views)
I don't quite understand why optimizing memory here is required as the data set does not seem very large.  That being said, clusters use (relatively) a lot of memory, and nested arrays/clusters are generally considered poor programming.  It seems to me that this can be handled with a 3D array (much more memory efficient):  3 pages for the time intervals, 7 rows for the physical quantities and an indeterminite number of columns for the individual elements.  How to handle the array depends on what are valid values for the individual elements.  If the data type is numeric and 0 is not a valid user input value, then it's easy.  Just build the array row by row.  Each row will have the number of columns equal to the largest number of individual elements entered.  Data that has not been entered by the user will be 0.  For example, at time interval 1:

PQ1: 9 2 7 4 1 8
PQ2: 8 7 2
PQ3: 1
PQ4: 4 6 8 2
PQ5: 2 3 4 5 6 7 8
PQ6: 4 2 7 9
PQ7: 2 4

The first page of the array would be:

9 2 7 4 1 8 0
8 7 2 0 0 0 0
1 0 0 0 0 0 0
4 6 8 2 0 0 0
2 3 4 5 6 7 8
4 2 7 9 0 0 0
2 4 0 0 0 0 0

If the data type is not numeric or 0 is a valid value, I would initialize a 3D array that is 3 X 7 X (something larger than the max # of individual elements) with some sort of invalid value.  Then, as  the user inputs individual elements, replace the appropriate array element.  This also has the advantage of creating the array ahead of time so LabVIEW will not have to create any memory buffers.

Hope this helps.

Dave.

==============================================

0 Kudos
Message 2 of 3
(2,523 Views)
My primary advice regarding memory management is AVOID BUILD ARRAY!  While most array operations are fairly memory efficient, build array is a real hog.

Also, the bigger the array, the bigger the memroy hit.  So try to do as many operations on as little data as you can.  It can require some rather creative wiring.
0 Kudos
Message 3 of 3
(2,508 Views)