From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Loop Time Increasing as Program Progress

My VI is a big state machine, all the states are taking couple of milli seconds when I start the program but after a while same states are taking lot of time (200 msec)I need a precision of atleast 10 msec going frmo loop to loop. Could any one tell me why this could happen. Is this something with the RAM? do I need to clear the RAM once in a while? I am not attaching my VI cause there are quite a number of Sub VI's in my Main VI. If need I can post my Main VI.

Thanks,
Mudda.
0 Kudos
Message 1 of 8
(2,878 Views)
What you describe is the classic symptom of a loop which appends data to an array or string on each iteration. As the data size gets larger, memory reallocation takes place and things slow down. Another possibility is that the amount of processing you do on the increasing amount of data also takes too much time. Use the Profiler (Tools>>Advanced>>Profile VIs..) to locate the parts of your program which are slowing down and using more memory.

Posting the main VI will probably be useful, so that someone may offer more specific suggestions.

Lynn
0 Kudos
Message 2 of 8
(2,867 Views)
if you are using win2k or xp, then using the task manager to check the memory as your application is running. Mostly likely you are having a memory leak in the software. If so, check places where array is built/modified and string is concatenated/modified.

-Joe
0 Kudos
Message 3 of 8
(2,866 Views)
Are you opening references of any sort (TCP, VISA, FILE, ActiveX...) without closing them?
Do you have structures that get bigger over time (like arrays).
The decrease in performance sounds pretty severe to me (on the scale of 50-100 times more). Does it continue to deteriorate?
If all this didn't help to point you in the right direction, you can post all your files. Click File>>Save with Options and select Development Distribution. All your VIs will be saved into an LLB file, which you can upload.

___________________
Try to take over the world!
0 Kudos
Message 4 of 8
(2,864 Views)
I am doing the same operation all the time. I am storing the data to an array but they are not so big may be upto 30K samples. Just as a reference I am going to attach a sub VI, which is taking 1 to 2 secs at the beiging of the program and later on its taking about 200msec to execute. If any one needs my whole group of VI's I can attach them all.

Thanks,
Mudda
0 Kudos
Message 5 of 8
(2,840 Views)
Could you post the main VI instead?

How do you measure the execution time? Is it speeding up? (200ms is faster than 1-2 seconds). 😉

Message Edited by altenbach on 03-25-2005 09:55 AM

0 Kudos
Message 6 of 8
(2,836 Views)
I mean to say, couple of milli seconds at the begining of the program and more as it progress.

I am storing all the state strings and the milli seconds to a file and I wrote another VI to look at different states and the time it took to come out of that state.

I am attaching my Main VI, If any one needs anything please let me know.

Thanks,
Mudda
0 Kudos
Message 7 of 8
(2,828 Views)
You should place a few indicators to monitor your array sizes. I don't like the resizing of arrays inside clusters but it is difficult to tell from the code exactly how they grow. You should initialize all your orange arrays at full size (e.g. filled with 0 or NaN) and then replace the elements as data appears.

Most of the program looks ok otherwise. However, I don't like the autoindexing on the lower loop boundary for the "millisecond" and "next event". You should open the file outside the loop, then simply append the new values to the file inside the while loop on iteration at a time. Once the loop finishes, close the file outside the loop on the right side.

Currently, you are building an infinite-sized array on these indexing terminals.

To monitor timing, you could also simply put the milliseconds into a shift register and display the difference in a front panel indicator.
0 Kudos
Message 8 of 8
(2,815 Views)