05-07-2025 05:23 PM - edited 05-07-2025 05:26 PM
I trying to implement a circular buffer using LabVIEW queue. My understanding is that if I Obtain Queue and specify a fixed max queue size, the queue would not use more memory than what is required to hold the said number of elements. I then use Lossy Enqueue to keep just the fixed number of last elements in the queue. Nevertheless, the attached code quickly runs out of memory, which I can also see in Windows Task Manager.
Do I misunderstand the mechanics of Lossy Enqueue into fixed size queue?
LabVIEW version 2024.Q1
05-07-2025 06:12 PM
Why is the obtain queue in the loop? I understand it is named, but I think that is the issue with your example code. If I move it out of the loop runs in less than 1s, keep it in the loop LabVIEW freezes.
05-07-2025 10:10 PM
I want to pass the data between different parts of the application based on this excerpt from labview docs:
"Use named queues to pass data between two sections of a block diagram or between two VIs in the same application instance. If you wire name, the function searches for an existing queue with the same name and returns a new reference to the existing queue."
The plan is to call obtain named queue in each section of the code and enqueue or dequeue some data instead of developing overhead code to pass around queue reference.
Perhaps the part "returns a NEW reference" provides a clue why this method eventually runs out of memory.
05-07-2025 10:18 PM
Yes, new reference is key. From AI,
05-08-2025 02:04 AM
Hello Fedor,
please, post your VI in LV2023 format (or older).
05-08-2025 02:32 AM
You need one release for each obtain - unless you wire true to force destroy.
Obtain and Release Queue
How do you pass the queue name around? If you hard code the queue name on each block diagram, you have a hard time tracking its use. If you store the name in an FGV, you could just as well store the queue reference in it.
05-08-2025 02:47 AM
@mcduff wrote:
Yes, new reference is key. From AI,
LabVIEW has a limit of 1,048,575 for the number of simultaneously open references of each type. This limit is due to the finite amount of memory LabVIEW uses to store references.Exceeding this limit can lead to the "Memory is Full" error, indicating a reference leak where references are not being properly closed.
It is actually also explained in Help: Obtain Queue Function — "If you use the Obtain Queue function to return a reference to a named queue inside a loop, LabVIEW creates a new reference to the named queue each time the loop iterates.", that is.
05-08-2025 10:04 AM
Thank you all for the insight. I ended up putting a FGV-like wrapper around lossy enqueue to obtain and store queue ref in a shift register if the ref is not valid.