08-17-2020 06:18 AM
Hi all,
I had a problem for which I found a workaround, but I would like to understand why this is happening.
Consider the code snippet below.
I am binning a 2D array into a 1D array by transforming the 2D coordinates in order to get the average value and standard deviation of each bin. Because the number of elements is not the same for each bin I used a Build Array and stored this in an array of clusters.
This might not be elegant from a memory management pov but it performs well enough on the first run, a few hundred milliseconds. However each call takes significantly longer than the previous. The 2D array size is typically around 600 x 300 elements and the binned array size around a few thousand elements. After a few calls it can take over 10 seconds to execute, both in developer mode as in runtime environment. There does not appear to be a memory leak.
By using Request Deallocation the execution time stays more or less constant. It seems the initialization of the 1D array of clusters does not result in the same state as during the first call.
Is this a case of the LabVIEW compiler failing to outsmart the user? Am I making things worse by using the In Place Element Structure?
Solved! Go to Solution.
08-17-2020 06:23 AM
08-17-2020 06:53 AM
Hi Gerd,
It seems I underestimated the sizes.
See attached VI with typical values.
08-17-2020 06:58 AM
Since you're adding at the beginning of the Array it'll need to reallocate and copy the Array each time.
08-17-2020 07:07 AM
@Yamaeda wrote:
Since you're adding at the beginning of the Array it'll need to reallocate and copy the Array each time.
I tried adding at the end but that also does not seem to help for next calls.
Without deallocation:
With deallocation:
08-17-2020 07:07 AM - edited 08-17-2020 07:10 AM
Hi Ramon,
right-click the IPE and select "Remove IPE…", then save the VI.
This cuts down the loop times from ~800ms…3800ms (start to 5th iteration) down to ~400ms (for all iterations)! (LV2020, 32bit on Win8.1-64bit)
(Prepending or appending the new element to the inner array doesn't make a notable difference.)
08-17-2020 07:13 AM
@GerdW wrote:
Hi Ramon,
right-click the IPE and select "Remove IPE…", then save the VI.
This cuts down the loop times from ~800ms…3800ms (start to 5th iteration) down to ~400ms (for all iterations)! (LV2020, 32bit on Win8.1-64bit)
(Prepending or appending the new element to the inner array doesn't make a notable difference.)
That did the trick.
I guess it was a case of me failing to outsmart the LabVIEW compiler 😛
08-17-2020 07:40 AM
02-24-2021 05:42 AM
Hi GerdW,
How can I remove the IPE in LV2017?
02-24-2021 05:44 AM - edited 02-24-2021 05:44 AM