mje Posted March 11, 2009 Report Share Posted March 11, 2009 I have a class that stores some data in functional globals (FGs): this is essentially data that might be considered class/static data in other languages. The FGs are privately owned by the class. I'm worried about the lifetime of the VIs though, as ultimately I'm not familiar with how classes are handled and I'm dealing with a bunch of dynamically loaded VIs. If I'm not mistaken, a VI can unload from memory if the "owning" VI unloads, even if it's referenced elsewhere, and is one of the things you need to keep in mind when dealing with FGs. Do I run the same risks when dealing with class methods? That is, does the VI being owned by a class change the behavior at all? Can a class partially unload if the VI that brought the VIs into memory unloads? Heck, can an entire class unload if the referencing VI dies? -michael Quote Link to comment
Aristos Queue Posted March 13, 2009 Report Share Posted March 13, 2009 QUOTE (MJE @ Mar 10 2009, 12:56 PM) If I'm not mistaken, a VI can unload from memory if the "owning" VI unloads, even if it's referenced elsewhere, This is wrong. A VI stays in memory as long as there are any callers of it or there are open VI references to it. You're thinking of the VI *reference* which is not the same as the VI itself. A VI reference goes stale as soon as the VI that opened that reference stops running, and when it goes stale, if it was the last reference, then the VI can leave memory. But if the VI is referenced elsewhere, the VI will stay in memory.QUOTE Do I run the same risks when dealing with class methods? That is, does the VI being owned by a class change the behavior at all? A class loads all of its member VIs into memory when it itself loads. After that, things get complicated, but I'm going to gloss over a whole bunch of generally not applicable situations and say "and the VIs stay around until the class leaves memory, which is after the class is no longer referenced and the last piece of class data has been deallocated." Essentially, the answer is: yes, things are different and simpler, because the member VIs load with the class and there's no way to unload the class as long as your app is still running. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.