LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Global Variables and memory usage

Hi,
Question about GLobal Variables. If I have a Global Variable vi with 10 different items on it(a mixture of arrays, booleans, strings, etc.) and I use say a boolean in another vi, does it use the same memory as if I had used the array? In other words, would it be beneficial to have each Global Variable in it's own vi?

Also, is there a way to load global variables into memory and keep them there when the loading vi closes (like when a vi creates a reference to itself so it stays in memory when it's caller closes).

Thanks!
0 Kudos
Message 1 of 7
(3,698 Views)
I can not think of a way to keep globals in memory, but, by using the invoke nodes, you can use the methods, "Make current values default" and "Save VI" then any data that is stored in the global is available to another VI that uses the global variable.
0 Kudos
Message 2 of 7
(3,698 Views)
Hi Sal,

In terms of memory useage, dont think it matters whether you have ten booleans on one global panel or one boolean on 10 global panels.
The way I use the Global panel is to group common variables. So I would have Status.gbl vi file which would hold all my program status booleans etc. I find this easier to maintain my overall program structure.

While you have a VI in memory that is using the globals, then those globals will main in memory until all the VI's are closed.


Regards
Ray.
Regards
Ray Farmer
0 Kudos
Message 3 of 7
(3,698 Views)
As of today, you have 2 good responses - I'll add a 3rd for the cause - If you are looking for a way to keep values available, regardless if a certain VI is open or closed, you may want to consider a Write-to-File VI. Writing and Reading from a file (text file, etc.) becomes easy with Labview, and provides great flexibility when sharing data amongst various VIs, especially if they're not all open at the same time. Just an idea - Doug.
0 Kudos
Message 4 of 7
(3,698 Views)
> Question about GLobal Variables. If I have a Global Variable vi with
> 10 different items on it(a mixture of arrays, booleans, strings, etc.)
> and I use say a boolean in another vi, does it use the same memory as
> if I had used the array? In other words, would it be beneficial to
> have each Global Variable in it's own vi?

I think that 10 VIs with 1 global each takes more memory that
1 VI with 10 globals. It is of course the same space for data storage
by itself but the VI panel takes resources that it is added for each global
VI.

> Also, is there a way to load global variables into memory and keep
> them there when the loading vi closes (like when a vi creates a
> reference to itself so it stays in memory when it's caller closes).
>

Obviously the Global
VI cannot open a reference to itself since it has
no diagram to run. However, it will stay in memory as long as one of
the following is true:
- a VI in memory (running or not) have a node to one
of the control of the global VI
- a reference is opened to the global VI (the hierarchy in which the
reference has been opened must stay running)
- its front panel is opened

Jean-Pierre Drolet
Scientech R&D


LabVIEW, C'est LabVIEW

0 Kudos
Message 5 of 7
(3,698 Views)
Thanks for all the answers!
0 Kudos
Message 6 of 7
(3,698 Views)
"Hi,
Question about GLobal Variables. If I write a Global Variable vi and using TestStand with 10 different items on it(a mixture of arrays, booleans, strings, etc.) and I use say a boolean in another vi, does it use the same memory as if I had used the array? In other words, would it be beneficial to have each Global Variable in it's own vi?
0 Kudos
Message 7 of 7
(3,698 Views)