≡ Menu

05 VISV Optimizing LabVIEW Class Loading with the Factory Pattern


VISV-002 ThumbnailIn this video tutorial, I share with you a technique that I use, when I want to be selective of how LabVIEW child classes load into memory. Specifically, by using the Factory pattern, I can dynamically load a class into memory and create an instance of a child class on-demand.

It's important to note that LabVIEW loads classes into memory automatically whenever class objects are used in VIs.

To demonstrate these concepts, I am using a code example from VISV 002. Take a look at that video if you want a more in-depth walkthrough of the code. Here, I attack the problem of how to limit loading of classes to only the ones you need for your current application run.

Download Code Used in this Tutorial: (LabVIEW 2009)

Hey, this is Michael Aivaliotis! Thanks for reading my post, listening to the podcast or watching the video on this page. When I’m not posting content on this site, I help companies develop automation powered by LabVIEW. If you want to find out how I can help you succeed with your next LabVIEW project – Contact Me.

  • If you don’t want to include the child classes in the EXE but rather provide them as a plug-in component, what is the best way to package them for distribution? (with diagrams removed, typedefs disconnected, etc)

    • John. I would build a source distribution for the child classes and just build an executable out of the parent class. I will do a follow up video in the future to cover this use-case.

      • FabiolaDelaCueva

        Michael, did you do this follow up video? Where can I find it?

  • Anonymous


    Wonderful presentation! Clear and effective! I especially like how you showed what is in memory when.

    For clarification:
    This is essentially what Head First Design Patterns terms a Simple Factory (often used, but not included as one of the Gang of Four patterns).
    If you take your method to load an object, put it in a class, make an interface class for that, and call the interface method in your application, you have the Factory Method Pattern, which is one of the Gang of Four patterns.

    I’m looking forward to the next video! Well done!


    • Thanks for your feedback and clarification Paul. I’ve been using objects in LabVIEW for only a fraction of my entire LabVIEW career. I’m still in learning mode and am constantly pushing myself to explore and learn new patterns.

  • Ray Farmer

    although a child doesn’t start of in memory, once loaded it appears to stay in memory. Can it be unloaded  at the cleanup

    • Nope, talk to NI :). There is no way currently to unload a class once it has been loaded into memory.