LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform graph memory allocation problem

Hi all!

 

I developed an application with a tab structure which acquires data and plots it to five different waveform graphs.

 

In order to save memory, to store the acquired data, instead of using an external array structure (one for each graph), i chose to use the graph itself (see attached picture).

 

Each graph is initialized with about 1000000 samples with a value of 0. The updating process consists in adding the new sample and deleting the oldest one. This should ensure the keeping of a constant total number of samples.

 

When the application is running, taking a look to the Windows XP Task Manager, i noticed what follows:

 

1 - The memory allocated initially is about 880 MB

2 - When the selected tab doesn't contain a graph (thus, no graph is visible), the memory allocation practically does not increase (300 KB after 48 hours)

3 - When the selected tab contains a graph (thus, a graph is visible), the memory allocation increases with a certain velocity (50 MB after 24 hours), possibly leading to an "Not enough memory to complete this operation" system error

 

The error mentioned should be avoided, in order to prevent the loss of communication with some external devices.

 

Does anyone has any clue to solve this problem? Any suggestion on how to improve the attached code?

 

Many thanks!!

0 Kudos
Message 1 of 6
(3,696 Views)
Some ideas :
Property nodes require thread switches so probably better to use arrays for data storage.
Adding to and deleting from arrays is bad as each will cause a resize. Consider a circular buffer by maintaining a pointer to the first element in the data and use replace array element.
Both of these should help. Labview has to find contiguous memory to store arrays which becomes tough when large arrays are continually resized.
Consider using sgl instead of dbl. But be mindful of the prescision.

Michael.
0 Kudos
Message 2 of 6
(3,690 Views)

Useful suggestions, but those don't explain the descripted behaviour, which seems related somehow to the graphic memory.. Isn't it so?

0 Kudos
Message 3 of 6
(3,679 Views)
All I can say is when the graph is visible labview has to redraw when the data is changed. If it is hidden then the data changes but no redraw occurs. Could labview be double buffering in the visible case? I suspect the behaviour would be fixed if you follow my original suggestions. It would be good practice to decimate the array and not send 1000000 points to the graph. This can be difficult if you need to let the user zoom, though.
Michael.
0 Kudos
Message 4 of 6
(3,677 Views)

after looking at the code image I suspect you are creating 3-4 copis of your data.

 

Data as displayed

Revert version (used for un-do ctrl-z)

Copy from the property node

Another to push into the property node.

 

Use your own explicit buffer (do not use the graph as a buffer becuase you can not work in-place in the graph) and push it to the graph when it changes.

 

If you keep your explicit buffer fixed size then you memory should remain stable (provided there are not other memory abuses).

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 6
(3,671 Views)

Hi again!

 

RiversDaddy suggested in a previous post to realize a circular buffer to store acquired data, unsing an array and keeping trace of the first element with a pointer. That's what i did so far..

 

I'm wondering now which is the correct (and best, in terms of efficency - CPU load and memory allocation - ) way to handle the data in order to plot it to a waveform chart.

 

Thanks in advance!

0 Kudos
Message 6 of 6
(3,632 Views)