Table Of Contents

Obtain Queue (G Dataflow)

Last Modified: January 12, 2018

Returns a reference to a queue.

Use this reference when calling other nodes that perform queue operations.


max queue size

The maximum number of elements you want the queue to hold.

If a queue with the same name exists, the node ignores this input and uses the maximum queue size from the existing queue.

Preallocating Memory for Queues

To preallocate memory for a queue, enqueue the number of elements you want to include and then flush the queue. The memory remains allocated for further use of the queue.

What Happens When Maximum Queue Size Is Reached?

If a queue reaches the maximum queue size, the Enqueue Element or Enqueue Element at Opposite End nodes wait until the Dequeue Element or Flush Queue nodes remove elements from the queue.

Default: -1 — The queue can hold an unlimited number of elements.



The name of the queue that you want to obtain or create.

Default: Empty string — Creates an unnamed queue.


element data type

The type of data that you want the queue to contain.

You can wire any data type to this input.


create if not found

A Boolean value that determines whether to create a new queue if one with the same name as name does not exist.

True The node creates a queue if one with the same name as name does not exist.
False The node does not create a queue if one with the same name as name does not exist.

Default: True


error in

Error conditions that occur before this node runs. Unlike most nodes, this node runs normally even if an error occurs before this node runs.

Default: no error


queue out

A reference to an existing queue or to a new queue created by this node.


created new?

A Boolean value that indicates whether this node created a new queue.

True This node created a new queue.
False This node did not create a new queue.

error out

The node produces this output according to standard error behavior.

This node can return the following error codes.

1094 You tried to obtain an existing queue or notifier reference with the incorrect data type. You can get this error when you obtain a reference to the same queue or notifier but do not wire the same data type as the original specified data type. Unnamed queues and notifiers do not have this restriction, because each request to obtain an unnamed queue or notifier creates a new reference.
1100 You tried to obtain a queue or notifier that does not exist, so no reference could be returned. You can use the Obtain Queue or Obtain Notifier nodes to look up a queue or notifier by name. This error occurs if create if not found is set to False, and a queue or notifier with the name you specify was not found.
1548 A queue reference cannot be obtained with a maximum queue size of zero. The max queue size input must either be a positive number or -1 for unlimited size.

This is not a comprehensive list of errors this node can return.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Queue Memory Usage

When you enqueue and dequeue elements with resizable data types, such as paths, strings and arrays, you do not affect how much memory the queue uses. Queues transfer data but do not generate copies of the data.

Preventing Unintended Memory Allocation Inside a Loop

When called inside a loop, the Obtain Queue node creates a new reference to the queue each time the loop iterates and memory usage increases because each new reference is an additional four bytes. These bytes are released automatically when the VI stops running. However, in a long-running application, there may appear to be leaking memory as memory usage keeps increasing. To prevent unintended memory allocation, use the Release Queue node in the loop to release the queue reference from memory for each iteration or use Obtain Queue once before the loop begins executing.

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported

Web Server: Supported in VIs that run in a web application

Recently Viewed Topics