LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory Resize and Relocation

Solved!
Go to solution

Dear All,

 

I am displaying values with respect to time in graph, and i want to limit the array size to 1000 for 16 different channels.

 

when i am running the code for 2 days continous then i CPU usages shoots up to 50% but not the memory, and the processing is slowed down.

 

 

I know the memory is resized and located at different location every time.

 

Is there a better way to do it, or any resources are there to implement this thing in a better way ?

 

attached is the sample code.

Download All
0 Kudos
Message 1 of 6
(2,476 Views)

You are constantly growing and shrinking arrays, which is highly inefficient because it needs to recopy and reallocate the array. A "no code" solution would be a "waveform chart" in the main VI with a history size of 1000.

 

If you want to do it with a subVI, initialize the shift register with a fixed number of elements and replace elements while rotating the array in place, for example.

 

 In addition, the terminals in the subVI belong outside the loop.

Message 2 of 6
(2,469 Views)
Solution
Accepted by topic author shrekt

Here's a quick draft on how you could do it operating fully in place. (also make sure the panel if the subVI is closed, else you'll need extra memory for the complicated indicators).

 

Here's the code of the modified subVI that handles 16 channels with a 1000 point history:

 

 

Download All
0 Kudos
Message 3 of 6
(2,448 Views)

Thank you for the example.

 

i tried to implement your code but the processing of the CPU now also increases upto 50 as soon as the history size is crossed.

 

note: i have not used your examples as it is, with some modification i have used.

 

any suggestions.

0 Kudos
Message 4 of 6
(2,414 Views)

shrekt wrote:

note: i have not used your examples as it is, with some modification i have used.

 

any suggestions.


There is exactly one possibiltiy to copy my code, but there are millions of ways to do modifications. Unless you tell us what you did, we cannot help. Please show us what you have done.

 

if your memory increases, obviously you are not operating "in place" and whatever you did has nothing to do with my example.

 

(Do you have a dual core system? 50% CPU uses seems like one core running at 100%.)

0 Kudos
Message 5 of 6
(2,394 Views)
Up to your last post you talked about memry problems. Is that solved? Cpu use is often completely unrelated. What is your loop rate? What is your history size? Do your loops contain any pacing or do they spin as fast as the computer allows?
0 Kudos
Message 6 of 6
(2,386 Views)