LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

New buffer is allocated in while loop with constant initialize array?

Hello,

Is it strange behevior or is there a logical explanation for this?

look the images, one with constant and one with control,

the array with constant is making another copy when it enter the loop. why is that?

 

 

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

Ben sheds some light on this topic here:

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=163926&query.id=119062#M163926

 

-AK2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
Message 2 of 4
(3,087 Views)

Thanks!

thats really helpful

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

On LAVA there is another (very helpfull) discussion.

With the following conclusions:


You are initializing the 8MB array using constant values. The output of that Initialize Array function is always going to be the same, so LabVIEW constant-folds it out by putting the actual array in the executable code during compile-time. The result is exactly the same as if you had placed an array constant with a million elements in it on the block diagram.
http://forums.lavag.org/Why-does-the-Replace-Array-Subset-double-the-used-memory-t10135.html#

 B) Your instincts are correct that we ought to be able to consolidate in this situation. EXCEPT... your inputs to the Initialize Array function are all constants. That means that Initialize Array has been constant folded and the buffer is there in your VI's save image. To avoid stepping on the value of the constant when we run the loop, the shift register makes its own copy. If you change any of those initial constants into controls, the buffer copy will go away.
http://forums.lavag.org/Why-does-the-Replace-Array-Subset-double-the-used-memory-t10135.html#

 

 Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 4 of 4
(3,069 Views)