03-09-2009 08:41 AM
If you have a queue with all of its elements de-queued, does it still exist in memory?
Meaning, is it necessary to use a 'Release Queue' function on an empty queue?
Or is that just used to obtain the remaining elements?
Solved! Go to Solution.
03-09-2009 08:50 AM
03-09-2009 08:55 AM
As far as I know, Adnan is correct - when an element it put into the queue, LabVIEW keeps that area of memory for the queue even after the element is dequeued to improve performance.
That said, this is an implementation detail. It's possible that the memory block is released if the queue hasn't used it for X time, etc. In general, you should release a queue when you're done with it. Another alternative is to use the request deallocation primitive, which will probably clean up this memory as well. Note, however, that you should only use it in cases where you have a large memory block which is not going to be in use again.
03-09-2009 09:03 AM
Adnan Z wrote:
[...] To destroy a queue, call the Release Queue function a number of times equal to the number of times you obtained a reference to the queue [...]
Just want to ensure the correct understanding of this sentence:
You have to release each reference you obtain once. So if you only obtain a single reference, a single release will do it.
If you obtain the same queue in two different places in your VIs, you have to release each reference on its own once. Trying to release an already released queue reference will create errors.
hope this helps,
Norbert
03-09-2009 09:04 AM
Norbert B wrote:
Adnan Z wrote:
[...] To destroy a queue, call the Release Queue function a number of times equal to the number of times you obtained a reference to the queue [...]Just want to ensure the correct understanding of this sentence:
You have to release each reference you obtain once. So if you only obtain a single reference, a single release will do it.
If you obtain the same queue in two different places in your VIs, you have to release each reference on its own once. Trying to release an already released queue reference will create errors.
hope this helps,
Norbert
Thanks for the clarification Norbert. So since I am only referencing the queue in a single VI,
only 1 release is neccessary, correct?
03-09-2009 09:06 AM
That is correct Cory.
Thanks Norbert, that is what I had meant. I apologize for the confusing statement.
03-09-2009 09:12 AM
tst wrote:As far as I know, Adnan is correct - when an element it put into the queue, LabVIEW keeps that area of memory for the queue even after the element is dequeued to improve performance.
That said, this is an implementation detail. It's possible that the memory block is released if the queue hasn't used it for X time, etc.
I'd be interested in knowing more about this. I had assumed that when you dequeue an element, LabVIEW will keep that area of the memory for as long as the queue is being referenced to (Release Queue has not been called yet). Only AFTER Release Queue has been called will the memory block be released.
03-09-2009 09:30 AM - edited 03-09-2009 09:32 AM
Adnan Z wrote:
[...]Only AFTER Release Queue has been called will the memory block be released.[...]
Nope, tst is correct. LV keeps the memory in the asumption that the queue could use that memory again. But if the application runs out of memory somewhere else, LV will reallocate that memory to the new area.
Small example: You enqueue many large elements like structs, arrays or strings. So for a (short?) time the queue eats a huge amount of memory. If you start dequeueing, LV will still keep that memory in order to fasten up new enqueues.
But if the application needs more RAM for e.g. a large array, LV could use memory from the queue.
Request Deallocation could help in accelerate the freeing of the memory, but experience shows that 99.9% of all usages, that primitive does nothing....it's only a request afterall, isn't it? 🙂
hope this helps,
Norbert
03-09-2009 01:18 PM
Haha, is there anything in LabVIEW that you guys dont know?
Aha! I've got one :
What is the largest modification that will be made in LabVIEW 10.6?
09-03-2016 09:43 AM
I dont understand. If I obtain the same Queue multiple times, that means I am typically accessing a single Queue. Most probably the reference will point to the same memory location of the Queue. Then if I release the Queue once that means I am not using the Queue anymore right. Why should I release it as much time as I am obtaining it?