LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array subset uses twice as much memory

Actually it's not all that different from any other programming language, allocating an array requires continuous memory.

"char[1000000000] megastring" can be rather hard to perform also.

 

The solution in C (and derivatives) is linked lists which'll split the memory up.

In LV you can (probably) achieve the same thing through Arrays of Arrays. Technically that means Array -> Clusters -> Arrays.

 

Why cluster? It means each array can be of individual size and a different type that the cluster array.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 21 of 26
(3,785 Views)

@Yamaeda wrote:

...

 

The solution in C (and derivatives) is linked lists which'll split the memory up.

In LV you can (probably) achieve the same thing through Arrays of Arrays. Technically that means Array -> Clusters -> Arrays.

 

Why cluster? It means each array can be of individual size and a different type that the cluster array.

 

/Y


1) Create multiple queues with a fixed number of elements in each (1 is enough)

 

2) Put the refs for those queues in an array.

 

3) Use the queues as if they are portions of the buffer.

 

Since the queues work in-place and they are sepearte allocations.

 

So your idea is possilbe in LV.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 22 of 26
(3,783 Views)

Clippity Clock, Clippity Clock, Klunk

The sound of me falling off my high horse.

(Ben, Thanks for the insight).

 

I would like to revise my statement.

"I have exprienced unpredicted, inconsistent behavior with memory usage when using Array subset in a shift register state machine."

Let this be a lesson or warning to other users and information to National Instruments to help the continual improvement and performance of a great programming language.

 

I found and implimented a solution long before I posted in this forum, it's origins were an innocent method to avoid dropping down a graphicaly bulky, empty cluster array, constant,

and had hoped that my loss of many hours of investigation time would not go in vain and could be helpful to other users.

 

As to the comments programming in C,as I would be in control of memory is allocation, I would have declared the storage array once only and only created an additional array after the array subset size was known. In the code example, I would have used Array start and end pointers which would have used almost only a few cpu cycles.

 

On a positive note, 3 cheers to the labview team for giving us inplace and data value references to hand back predicatable memory use and optimisation to the user. These were not available when I trained on early LV8 versions..

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
Message 23 of 26
(3,759 Views)

@Timmar wrote:

...

On a positive note, 3 cheers to the labview team for giving us inplace and data value references to hand back predicatable memory use and optimisation to the user. These were not available when I trained on early LV8 versions..


"Back in the day..." of LV 5...

 

Memory management was even more challenging!

 

For loops were not albe to preallocate array for the output tunnels and we had to use "Init array shift refgisters and replace array sub-sets to get the perfomance modern users get from just dropping a foor loop with an output tunnel.

 

"Add" function could re-sue the buffer OF THE TOP input only and you had to think about which was the more efficient input to use.

 

Queues were not polymorphic and data had to be flattened before being place in the queue and unflattened on the back side.

 

There are many wonderful things added to the VL environment.

 

One that you did not mention is the

 

Tools >>>> Profile >>>> Show buffer allocations.

 

That used to be implemented as a non-supported ini switch and you had to click on each wire to find out about buffers.

 

Yes LV is getting better. THe more we lern about it the better behaved it is.

 

Take care,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 24 of 26
(3,740 Views)

 


@Ben wrote:
1) Create multiple queues with a fixed number of elements in each (1 is enough)

 

2) Put the refs for those queues in an array.

 

3) Use the queues as if they are portions of the buffer.

 

Since the queues work in-place and they are sepearte allocations.

 

So your idea is possilbe in LV.

 

Ben


 

Heh, yeah that's a pretty accurate linked list.

I was mainly thinking in terms of a linked list being able to use up all memory as each allocation is small, would an Array of clusters of array require continous memory, or would each clustered array be separate? Logically it should and you could use all memory.

 

/Y

 

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 25 of 26
(3,725 Views)

@Yamaeda wrote:

 


@Ben wrote:
1) Create multiple queues with a fixed number of elements in each (1 is enough)

 

2) Put the refs for those queues in an array.

 

3) Use the queues as if they are portions of the buffer.

 

Since the queues work in-place and they are sepearte allocations.

 

So your idea is possilbe in LV.

 

Ben


 

Heh, yeah that's a pretty accurate linked list.

I was mainly thinking in terms of a linked list being able to use up all memory as each allocation is small, would an Array of clusters of array require continous memory, or would each clustered array be separate? Logically it should and you could use all memory.

 

/Y

 


It does and I have done exaclty that.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 26 of 26
(3,720 Views)