Why Does My SubVI Freeze My Main VI?

Updated May 16, 2019

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.
  • What could be happening with this subVI?

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. 
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.

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.

WAS THIS ARTICLE HELPFUL?

Not Helpful