LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is this really a 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 5
(4,481 Views)

Hi Siddhu,

Could you please post some sample code or an image?

How you organize your data really depends on the relationship of the various data entities and what you plan to do with it.

I would like to be of more help but your question was sufficiently abstract to leave me wondering what I can do to help!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 5
(4,468 Views)

Hi Ben!

          Sorry for making the question so abstart. Generalizing my question with an example.

My question with reference to the vi I have attched is does each element in the main array( Here it is main cluster) occupy same amount of memory irrespecive of the no of elements in the arrays present in cluster 1 and cluster 2.

Siddhu

0 Kudos
Message 3 of 5
(4,442 Views)
yes they take the same amount of memory weather you have data in them or not
0 Kudos
Message 4 of 5
(4,414 Views)
 

Yikes!

 

If there was ever a time I could use Greg McKaskle's help it would be now.

 

I will do my best, so here goes.

 

App note 154 found here

http://zone.ni.com/devzone/conceptd.nsf/2d17d611efb58b22862567a9006ffe76/370dfc6fd19b318c86256a33006bfb78 

says,

"

Arrays
LabVIEW stores arrays as handles, or pointers to pointers, that contain the size of each dimension of the array in 32-bit integers followed by the data.

"

and goes on to say

"Clusters
LabVIEW stores cluster elements of varying data types according to the cluster order. .... LabVIEW stores scalar data directly in the cluster. LabVIEW stores arrays, strings, and paths indirectly. The LabVIEW cluster stores a handle that points to the location in memory where the data is stored.

"

So after reading that (doesn't app note 154 just thrill you? Smiley Wink ) and looking at you example I would be tempted to say that because you are asking about an

array of

clusters of

clusters of

arrays

then all we have is a bunch of pointers to data that is elsewhere and I would have to agree with vivi's posting.

But that is only talking about how the data is organized in memory and does take into concideration what LV is doing with that data and also draws a very fine line between THE CLUSTER adn the DATA IN THE CLUSTER.

In C you have to keep that stuff in mind. In LV, the data in memory is kinda worthless unless you "touch" it in some way.

To illustrate that clusters and arrys are the the handles+data I put together the following code.

As shown buffers are allocated in the initial frame and re-used the rest of the example.

I have configured the two controls "Main Array" and "Main Array2" such that the both contain a single element.

The single element in "Main Array" only has a single element in the array of the first of its sub-clusters.

The single element in "Main Array2" has 10,000 values in the array in the first sub-cluster.

So since I am doing everything "in-place" (not creating new buffers) and if copying an array element is simply a matter of copying a handle over-top of itself, THEN it should take the same amount of time to replace element 0 with element 0 for both "Main Array" and "Main Array2".

Running the VI shows that this is NOT true. The small array 50ms and the large about 9 seconds.

So...

While I am developing in LV I do not think about how the data structure is stored but more about how much memory is required to store the data in the wire, and try to minimize how many times that data is duplicated.

 

I expect there will be follow-up Q's so let them fly!
 
Ben

Message Edited by Ben on 11-10-2005 05:47 PM

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Download All
Message 5 of 5
(4,399 Views)