Queue memory leak when non-reentrant VI destroyed without explicit close
0 reputation · 08 Sept 2025, 16:27 UTC
0 reputation · 08 Sept 2025, 16:27 UTC
LabVIEW queues allocated inside a non-reentrant VI persist after the VI finishes execution if Release Queue is not called. The memory profiler shows heap growth proportional to the number of VI invocations, but the documentation does not clarify whether the leak is bounded by the VI's lifetime or accumulates across the application session.
Determine the exact cleanup semantics for queue references created in non-reentrant VIs when the caller does not explicitly release them.
Obtain Queue inside the VI.Release Queue call exists in the VI or its callers.37275 reputation · 08 Sept 2025, 21:34 UTC
LabVIEW does not automatically release a queue when a non-reentrant VI finishes or becomes idle. A queue created with Obtain Queue is an application-scoped resource. If Release Queue is never called, the queue and its backing heap memory remain valid for the rest of the application session. The heap growth you observe is therefore session-scoped, not bounded by the VI’s lifetime.
Release Queue calls, not by VI instance destruction.Each invocation of the non-reentrant VI creates a new queue object. Because nothing releases it, the objects accumulate until the LabVIEW application shuts down. This matches heap growth proportional to invocation count.
Obtain Queue.Release Queue before the VI terminates, wiring the same queue reference.Release Queue call to the caller that destroys the reference.Does this VI pass the queue reference out to another VI or store it in a functional global, or is the queue created and used entirely inside the VI? This determines whether Release Queue belongs in this VI or in its caller.
Assuming LabVIEW 2023 Q3 or later: stricter global-data checks were introduced, but I have no confirmed documentation that those changes add automatic queue release at VI termination. Treat post-2023 automatic cleanup as unverified until you check the current release notes.
Obtain Queue in a loop and returns.Release Queue and repeat; growth should disappear if the queue was the only leak.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.