Why Does My SubVI Freeze My Main VI?

Updated Mar 9, 2020

Reported In

Software

  • LabVIEW

Issue Details

  • When I run my Main VI, it freezes, hangs, or holds unexpectedly. 
  • I suspect one of my subVIs is taking a long time to execute.

Solution

There are some possible causes that could explain this behavior:
  • This subVI has a while loop with an undetermined loop condition, that makes it execute infinitely. 
  • A specific function or node is freezing the subVI. 
  • Settings within VI Properties are causing the whole VI to be suspended when the subVI is called.
To resolve it can be considered to follow this steps:
  1. First, run the code using the Highlight execution to determine what particular subVI of the VI is freezing the execution of the application.
  2. After isolating the subVI in question, determine why the subVI does not continue its execution. This can be caused by a while loop without a defined conditional terminal, an Event structure waiting for an event, or a function waiting for an action indefinitely.
  3. Find an alternative or a way to replace the structure within the subVI that is freezing its excecution.
If the steps above do not work then you can edit the VI Properties settings of the subVI, to do this please follow these steps:
  1. Open the subVI and select File and then VI Properties.
  2. Select Execution from the Category drop down list as seen below; 
  1. Ensure that Suspend when called has not been checked and then press Ok;
  1. Run your Main VI again to check that this has resolved the issue.

If the issue persists despite these steps then please contact National Instruments Technical Support.

Additional Information

It is not recommended to have while loops within subVI's because they can cause the main VI to freeze inadvertently. However, if there is no other way to accomplish a certain task, Global Variables could be used to stop a while loop that is running within a subVI. The following code illustrates how this can be performed.
1. Main VI:
2.  SubVI:
In this architecture, in the Main VI two, while loops run in parallel, the first one is dedicated to updating the global variables, and the second one is dedicated to run the SubVI. This paradigm is inefficient, therefore should be used only when is strictly required.