08-28-2008 12:15 PM - edited 08-28-2008 12:17 PM
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?
08-28-2008 01:17 PM
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.
08-28-2008 01:30 PM
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
08-28-2008 01:41 PM - edited 08-28-2008 01:42 PM
08-28-2008 05:28 PM
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.