
509Memory-Related Techniques
time than simple function input arguments or local variables, which typically use
the stack or even CPU registers. So, if you are not using the persistence feature,
and do not have a copy-on-write situation to avoid, then you may wish to avoid
global variables.
• Global variables are generally unsafe in multithreaded environments. Since
MATLAB’s main computational engine is single threaded, this is one drawback
that does not seem to apply in MATLAB’s case.
As an alternative to using global variables, we could use MATLAB Desktop’s UserData
or ApplicationData properties to store global information (note that there ar ...