From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

VI run slowly after a specific time

Solved!
Go to solution

Hi,

I manage to  fix most of my problems seen by RavensFan, but I found that my CPU utilization increse with the running time of vi, and the problem is from the subvi  atached, which is used to build 4 XY Graphs for 8 plots. 

 

Please let me know if you have a clue, on how to solve this problem.

Ps: if I disable the plots, the cpu  utilisation stays normal.

 

Thank you,

Vlad

0 Kudos
Message 11 of 17
(1,584 Views)

How often do you reset the graphs?

 

How large are those graphs getting?

0 Kudos
Message 12 of 17
(1,579 Views)

So normaly, i reset them in about one hour, but sometimes I need to reset them after about 10 hours.

0 Kudos
Message 13 of 17
(1,576 Views)

And how often or how fast do you call this VI? Since you know that eight numerics and a time value are entered each time you call it, you can calculate how large the arrays will get.

 

You can open the front panel of the Express VI and then the block diagram to see how it accumulates data. What you see is generally the least efficient means of doing so.  Further, you duplicate a lot of data, possibly  making the arrays bigger than they really need to be.

 

Lynn

Message 14 of 17
(1,570 Views)

I call this subvi at each 100ms. But you are right, there is a lot of data. I will try to implement a function which performs reset operation of graphs after a specific time, because data is also saved in ascii files. 

Thank you,

Vlad

0 Kudos
Message 15 of 17
(1,566 Views)
Solution
Accepted by topic author vlad.mihai

Vlad,

 

So that means you have increased the size of nine 1D arrays and five 2D arrays 360000 times in 10 hours. In LabVIEW an the elements of an array are stored in contiguous memory locations. As the array outgrows the memory which was originally allocated for it, LV and, possibly the OS, must allocate new memory. If the memory becomes so fragmented that no contiguous space available is large enough for the new array, you will get an Out of Memory error (or a crash). But the reallocation and moving the data to the new locations can take a lot of time.  This is the root cause of the slow down you are experiencing.

 

The fix is to pre-allocate enough memory for the largest array you expect to use and then fill it as you go.  The attached modification to your VI shows one way to do that.  The while loop uses uninitialized shift registers to store the array data and the index between calls.  The first call? initializes the shift registers the first time build_graphs.vi is called.  The Express VI does something very similar. Quotient & Remainder keeps the index from getting larger than the number of rows in the array. The array is initialized with NaN (Not a Number) which does not plot on graphs.  If you initialize with zero, then the graphs all include points at [0,0] until the array is full.

 

Number of samples must be set to the maximum number of samples you will collect before reseting.  You should either set a default value or calculate from the expected duration of your runs.  I did not connect this control to the conpane of the VI.

 

I did not connect the XY graphs of the modiifed VI to the conpane so you will need to have the subVI front panel open to compare the new and old ways.

 

I removed the In Place Element Structure because it did nothing.

 

I also include a test VI which creates some simple data and plots it.  The default number of samples  in build_graphs.2.vi and the test VI is 10.

 

Lynn

Download All
Message 16 of 17
(1,539 Views)

Dear johnsold,

Thank you very much and sorry for the late reply, your solution work fine for me.

 

Best regards,

Vlad

0 Kudos
Message 17 of 17
(1,508 Views)