06-19-2012 04:25 AM - edited 06-19-2012 04:28 AM
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!!
06-19-2012 04:48 AM
06-19-2012 10:03 AM
Useful suggestions, but those don't explain the descripted behaviour, which seems related somehow to the graphic memory.. Isn't it so?
06-19-2012 10:11 AM
06-19-2012 10:45 AM
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
07-13-2012 08:47 AM
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!