When to use global variables?
Doesn't global variables take up a lot more memory then local ones to?
For example: Code:
Would it be better to register the variable in the function 'a_function' ? |
Re: When to use global variables?
Global variables are stored in memory throughout the existance of the plugin. (meaning until plugin_end I think, could be till the comp is turned off), so a global variable is better for using something many times because you are calling the same spot in memory over and over instead of creating new spots in memory every time you create a new variable.
So yes, if you are only using the variable once, make it within your function. |
Re: When to use global variables?
yes local veriables = only using once
global variables = more then once stock varaibles = can be passed by compiler if not used :up: |
Re: When to use global variables?
Quote:
Global variables are much faster though, as they're not deleted/created/filled each time they're needed. Like SweatyBanana said, however, the storage is retained throughout the plugin's execution (clearing it impossible, even setting it to 0 leaves it as unusable to other applications). |
| All times are GMT -4. The time now is 06:52. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.