LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array insert limitation

hi,

        may i know about string array inser limitation.i have string array i insert more than laks data.so i want know abt any limitation have in array insert.

0 Kudos
Message 1 of 13
(4,452 Views)

I believe the limit on the array size is going to be either:

1) Until you run out of memory on your computer (specifically...a contiguous free block of memory of sufficient size)

2) You reach the maximum possible index size (I32) of 2,147,483,647

 

Of course...reaching that limit is going to take a long time when you're only inserting into the array once per second! It's also generally better to pre-initialise the array when working with large data sets so you're not allocating new memory each time the loop runs.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 13
(4,445 Views)
What is 'laks data'? Does that refer to an actual number?
0 Kudos
Message 3 of 13
(4,428 Views)

@GokulGKM wrote:

... i insert more than laks data...


Sorry, I have no idea what you are trying to say here.

 

Growing arrays without upper limit is generally a bad idea, but if you only do it once per second, you should be OK for a long time.

 

In this particular case, yuo are actually using the wrong tool. Instead of "insert into array", you should use "build array" (image).

 

 

"Built array" is much safer and simpler to use because it will always append the single element at the end ot the current 1D array if wired in that order and that seems to be what you want to do here. "Insert into array" is a much more powerful tool and can cause problems, because if the index input is larger than the size, nothing will be inserted while if the index is smaller, the element gets inserted and existing values shifted up. This is much more advanced functionality that needed here.

 

It also makes no real sense to build your data as string array. Wouldn' it be more reasonable to built an array of I32 numerics instead? Same information!

 

 

0 Kudos
Message 4 of 13
(4,413 Views)

@altenbach wrote:

@GokulGKM wrote:

... i insert more than laks data...


Sorry, I have no idea what you are trying to say here.

 

Growing arrays without upper limit is generally a bad idea, but if you only do it once per second, you should be OK for a long time.

 

In this particular case, yuo are actually using the wrong tool. Instead of "insert into array", you should use "build array" (image).

 

 

"Built array" is much safer and simpler to use because it will always append the single element at the end ot the current 1D array if wired in that order and that seems to be what you want to do here. "Insert into array" is a much more powerful tool and can cause problems, because if the index input is larger than the size, nothing will be inserted while if the index is smaller, the element gets inserted and existing values shifted up. This is much more advanced functionality that needed here.

 

It also makes no real sense to build your data as string array. Wouldn' it be more reasonable to built an array of I32 numerics instead? Same information!

 

 


You forgot to add "a lot less memory used".

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 13
(4,377 Views)

billko wrote:

You forgot to add "a lot less memory used".


 Not a lot more until we get into the thousands. 😄

0 Kudos
Message 6 of 13
(4,369 Views)

Just for education purposes:

It was mentioned insert into array uses a lot more memory than build array in the same operation: append one element to the end of array.

How is it? What is the difference? In both cases array size is modified and both functions need to allocate new space.

 

Does insert into array always copy old data to new place and build array only when physical memory after original block does not permit?

Why insert into array can not figure out that old data do not need to be moved?

0 Kudos
Message 7 of 13
(4,330 Views)

Alexander_Sobolev wrote:

It was mentioned insert into array uses a lot more memory than build array in the same operation: append one element to the end of array.


I don't think that this was mentioned. Insert into array is a more complicated function because it can do more but also requires an additional input, complicating the code. I don't believe that there is a significant difference in memory usage for the two methods.

 

(I think the memory comment was regarding a string array vs a I32 numeric array to hold the data.)

0 Kudos
Message 8 of 13
(4,318 Views)

>> I think the memory comment was regarding a string array vs a I32 numeric array to hold the data.

Then yes, completely agree.

 

Though build array is also more efficient than insert into array in a not efficient vi under the same conditions. On my PC it is 10+ times faster:

Looks like in case of build array Labview (at least 2011) is automatically allocating memory for multiple iterations. I tried using it in while loop with variable number of iterations (condition to stop is that dummy part with Random), the same results. 

 

expand array (build).png

expand array (resize).png

PS: never insert into the beginning!

 

0 Kudos
Message 9 of 13
(4,307 Views)

Both code examples are of course functionally identical to just autoindexing the string at the output tunnel, which is even faster by approximately another order of magnitude.

 

I would not be surprised if the compiler recognized the "unconditional built array, appending a single scalar per iteration, and starting with an empty shift register" and takes some valid shortcuts, e.g. allocation the entire array at the start of the loop because it can calculate the final size. The "insert into array" wired to [i] adds another complication and the compiler might just do it the harder way, allocating new memory whenever more space is needed.

 

But yes, I wasn't quite aware of the dramatic speed penalty of "insert into array" because I never use it inside a loop. 😉 Thanks!

0 Kudos
Message 10 of 13
(4,296 Views)