From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queues

Solved!
Go to solution

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?

Cory K
0 Kudos
Message 1 of 14
(5,831 Views)
Solution
Accepted by topic author Cory_K
If all elements are de-queued, the queue will still exist in memory. 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 or stop all VIs using the queue reference. Or, you can use the force destory boolean input on the Release Queue if you don't want to call the function multiple times or stop all VIs using the queue reference. Destroying the queue will invalidate all references to the queue.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 2 of 14
(5,828 Views)

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.


___________________
Try to take over the world!
Message 3 of 14
(5,822 Views)

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 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 14
(5,814 Views)

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?

Cory K
0 Kudos
Message 5 of 14
(5,810 Views)

That is correct Cory.

 

Thanks Norbert, that is what I had meant. I apologize for the confusing statement.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 6 of 14
(5,806 Views)

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.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 7 of 14
(5,801 Views)

 


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 

Message Edited by Norbert B on 03-09-2009 09:32 AM
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 8 of 14
(5,791 Views)

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? Smiley Wink

Cory K
0 Kudos
Message 9 of 14
(5,746 Views)

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?

0 Kudos
Message 10 of 14
(4,892 Views)