02-17-2012 08:55 PM
I just uninstalled and re-installed LabVIEW 2011. I was hoping this would do something to lower the memory footprint. Alas, it did not make any difference. This is what I see:
- When I launch LabVIEW, it uses 94 MB even before I have opened a single VI, i.e. only the front end uses this much memory.
- When I open the VI (the size of the .vi file is 549 KB), memory usage goes up to 836.4 MB. This is before I have even run the program.
- Finally, when I run the program, memory usage jumps to 1.17 GB.
I find this memory usage grotesquely high. Can anyone please shed some light on what can be done? I have uploaded the VI. It's a rather simple VI.
Thanks,
Neil
02-17-2012 09:35 PM
Oops I am not at all able to open the VI it shows "Generic error" and "Not enogh memory". My 2GB RAM is not sufficent
02-17-2012 11:47 PM - edited 02-18-2012 12:42 AM
Your various graph contains almost 200MB of default data in your array indicators alone!
3x 4000x2000 2D DBL arrays
2x 2000 1D DBL arrays
1x 2000 1D DBL array.
and I am sure there are other additional copies in memory (and we don't even know what's happening in the missing subVI).
In addition you also have value property nodes of same. That should easily explain the memory use. You should keep the huge 2D arrays e.g. in a shift register instead. I would also clear the indicators and make the new value the default before saving.
You are displaying 4000x2000 array data in an intensity graph with 400x200 pixels. You carry around 100x more data than can actually be shown.
Why is there no toplevel while loop? Are you using "continuous run" mode?
02-18-2012 01:09 PM
Thank you for the very useful comments. Sorry for not including the subVI. I have uploaded it with this reply. You raised several points:
1) If I understand correctly, what you are saying is that when I open the VI, the data structures associated with the intensity charts and waveform graphs are initialized to default values (e.g. 0), so there is memory usage even before the program is run and anything displayed, right?
2) Is there an alternative to using the value property node that doesn't duplicate the memory content? (e.g. something like pointer or reference in C++?)
3) I don't know about shift registers but will read up on them and use them.
4) Regarding the clearing of the indicators, could you please tell me how to do that, without removing the color ramp settings? (Previously, I would use 'Make Current Values Defaults' while the charts/graphs were showing data. That would create a .vi file of 200 MB. Now I save defaults with charts/graphs showing nothing, but I guess that's not the same thing as clearing the indicators.)
5) You are correct that I am displaying 4000x2000 array data in an intensity graph with 400x200 pixels. But then I change the min/max of the charts/graphs to zoom into the region of interest; I can identify the region of interest only after displaying the full 4000x2000 array of data. I don't know if there is a way around this.
6) Yes, I use the continuous run mode instead of a toplevel while loop. Is there a disadvantage to doing that?
Thanks,
Neil
02-18-2012 01:52 PM - edited 02-18-2012 02:13 PM
nbf wrote:1) If I understand correctly, what you are saying is that when I open the VI, the data structures associated with the intensity charts and waveform graphs are initialized to default values (e.g. 0), so there is memory usage even before the program is run and anything displayed, right?
Yes, a huge array still takes a lot of memory, even though it compresses well for storage inside the VI. Once the VI is ready to run, these arrays need to be allocated in memory.
nbf wrote:2) Is there an alternative to using the value property node that doesn't duplicate the memory content? (e.g. something like pointer or reference in C++?)
One possiblity are data value references. You can open a DVR and fill it inside the subVI, then extract slices later as needed. If done properly, you can also keep the 2D data in a shift register (yes, please learn about them!).
nbf wrote:4) Regarding the clearing of the indicators, could you please tell me how to do that, without removing the color ramp settings?
The color ramps can be set programmatically using property nodes based on array min&max and you can assign colors for the ramp values at will.
@nbf wrote:
5) You are correct that I am displaying 4000x2000 array data in an intensity graph with 400x200 pixels. But then I change the min/max of the charts/graphs to zoom into the region of interest; I can identify the region of interest only after displaying the full 4000x2000 array of data. I don't know if there is a way around this.
Do you really need to show the 2D data in three different transforms? Maybe one intensity graph is sufficient. You can apply the other transforms on the extracted slices with <<1% of the computing effort. What is the range and resolution of your data? Do you really need DBL or is a smaller representation sufficient (SGL, I16, etc). From looking at the subVI, the raw data is U16. The subVI also involves a coercion to DBL, requireing another data copy in memory. When running, make absolutely sure that the subVI front panel is closed, else additional memory is used for the huge array indicator there. For better performance, you might want to flatten the subVI to the main diagram or at least inline it.
@nbf wrote:
6) Yes, I use the continuous run mode instead of a toplevel while loop. Is there a disadvantage to doing that?
As Samuel Goldwyn ("A hospital is no place to be sick") might have said: "Run continuously is no way to run a VI" 😄
Run continuously is a debugging tool and has no place in typical use. What it basically does is restart the VI automatically whenever it completes, and as fast as the CPU allows. It is mostly useful to quickly test subVIs that don't have a toplevel loop and play with inputs to verify results. Any toplevel VI needs a while loop surrounding the core code. Period! 😄
So, my suggested plan of action would be:
See how far you get. 😉
02-18-2012 02:31 PM
Could you also attach a typical data file? Thanks!
02-18-2012 05:57 PM
Thank you for the prompt reply. The input file is too large to upload (~15 MB), but I uploaded it to my dropbox:
http://dl.dropbox.com/u/62957002/3033%20-%20IP%201%20sys%20shot.img
You are correct that the raw data is U16 and I thought it was a low-hanging fruit to remove the coercion to DBL or at least coerce to something smaller; I changed the representation of the subVI output data array from DBL to U16, I16, and SGL. Surprisingly, none of them worked; SGL even made LabVIEW crash; so I switched back to DBL.
I tried clearing the indicators using Edit -> Reinitialize Values to Default, but it didn't seem to make a difference. How does one clear indicators?
I will create a version of my VI following your suggestions and will report back.
Many thanks,
Neil
02-18-2012 07:48 PM
There is an option for arrays on the right click menu "Data Operations" then "Empty Array". Then right click Data Operations, Make Current Value default.
02-18-2012 10:53 PM
(He does not have arrays, just graphs: ---> right-click...data operations...clear graph.)
Here's a quick draft still retaining all your (potentially unecessary) graphs and functionality. Many things could be improved further, but this can give you hopefully some ideas. My advice from the earlier post still applies. (Many are not implemented in my example).
With all graphs loaded, it uses about 400MB in memory.
02-19-2012 02:08 AM
Thanks very much for the draft.