I do use Global/Public Variables sparingly and only if it’s rewarding enough in many ways.
From what I can understand, the moment a variable is declared then the computer reserves a specific memory space for it for later use.
And if I got it right, a variable which is only declared to have a scope within a specific procedure, when the procedure ends, so is also the life of that variable. In other words the memory space which was allocated to that variable gets released/freed.
To my main question:
- Are there any ways to release/free the memory space which was allocated to a Global (Public) variable when it was declared?
Some research, reflections and sub-questions:
a) I have done some googling and seen people suggest placing an “End Statement” at a desired location within the code. Does this really release/free the memory space which was allocated to the Globally/Publicly declared variable? Or does this only “purge” or “reset” the variable to carry no assigned value or object at all (in other words the memory space which was allocated to the variable when the variable was declared is still allocated to it)?
b) I have also seen people set a Globally/Publicly declared variable equal to Nothing or Empty. But same question here. Does this really release/free the memory space which was allocated to the Globally/Publicly declared variable? Or does this only “purge” or “reset” the variable to carry no assigned value or object at all (in other words the memory space which was allocated to the variable when the variable was declared is still allocated to it)?
c) Does “Deleting” or “Killing” a Global (Public) variable release or free the memory space which was allocated to the variable when it was declared? Or does this only “purge” or “reset” the variable to carry no assigned value or object at all (in other words the memory space which was allocated to the variable when the variable was declared is still allocated to it)?