LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is the Queue in Labview a Circular buffer? Performance questions and general question about release queue

I'm trying to optimize my program, and right now I have about 250+ fixed arrays (they are buffers) sizes each containing 30 elements or more behaving like a buffer/queue, where the array is filled up, and the last elements are popped of every seconds. (I'm processing large amounts of data.) Right now I'm just using the standard delete element from the array.

 

I was wondering should I replace those arrays with the built in Labview queues? Does the Labview queue use a circular buffer if I define the max size? Would that give me a better performance in terms of memory usage?

 

Also what does release queue actually do? Does it dereference the pointer or does it delete the queue from memory? Should I only call release queue when I'm finished with the queue? Should I have a release queue whenever I have a obtain queue?

Message Edited by d1sturbanc3 on 08-28-2008 12:15 PM
Message Edited by d1sturbanc3 on 08-28-2008 12:17 PM
Message Edited by d1sturbanc3 on 08-28-2008 12:17 PM
0 Kudos
Message 1 of 5
(6,919 Views)

The LabVIEW queue doesn't use a circular buffer if you define the maximum size, nor does it preallocate the memory (according to the documentation). LabVIEW 8.6 does have a lossy queue, which can allow you to use it like a circular buffer if you use the preview primitive.

 

Generally, when you enqueue an element, dequeuing it does not require any additional memory allocation since you have a 1-to-1 relationship. LabVIEW simply uses a pointer to the original memory location. This assumes that the wire wasn't forked before it was enqueued, because then you might get a copy.

 

Release Queue destroys the reference wired into it (which takes 4 bytes) and if it's the last reference or if you used the force destroy input, the queue itself will be destroyed as well and its memory should be released. You should usually call one release queue for each obtain, but it shouldn't really matter if you destroy the queue, since all those references will be released. In any case, just make sure you don't obtain references to the queue in a loop.

 

If you want a circular buffer implementation, you can also look at the example I posted here, which maintains a constant memory footprint.


___________________
Try to take over the world!
0 Kudos
Message 2 of 5
(6,900 Views)

There is a thread on the LAVA forums that discusses queues and their implementation details.

 

The Lossy Enqueue Element added to version 8.6 made me VERY  Smiley Happy

 

 

 

0 Kudos
Message 3 of 5
(6,881 Views)
okay cool. We have a subscription and should have 8.6, but our license guy doesn't have the image :(. I'll go hound at him.
Message Edited by d1sturbanc3 on 08-28-2008 01:42 PM
0 Kudos
Message 4 of 5
(6,876 Views)

Didn't notice the addition of the Lossy Queue function, cool.

 

Now if we could get them to add a class based (or simpler) priority queue.

Jon D
Certified LabVIEW Developer.
0 Kudos
Message 5 of 5
(6,845 Views)