I'd like to open a general discussion about module level variables in ACE 2.0. I am particularly interested in impact on CPU usage, and how to avoid garbage collection that may put module level variables out of context.
Here's my starting point. The PI ACE user manual for ACE 1.2.32 and 2.1.32 gives an example on page 139 showing that module level variables should be used when possible to avoid allocating and instantiating variables over and over again within a subroutine. The example given uses the vb6 "set" command syntax, so it seems clear to me that the example was written in the context of vb6 programming.
I'm not sure that the same CPU optimization technique can be applied successfully for ACE 2.1.32 using vb.net, because I wonder if garbage collection will eventually cause the module level variables to go out of context. Then the ACE program would need to catch the exception and revive the missing module level value.
It would be nice if ACE does some "behind the scenes" work to protect any module level variables from garbage collection. Can anyone tell me if that happens? If I use module level variables to save CPU processing in ACE 2.1.32, how should I deal with possible garbage collection issues that may cause these module level variables to go out of context? Have appropriate protections for module level variables, such as setting a variable to static or using a property function, been already built into ACE behind the scenes? Or do I need to build that type of protective code explicitly?