I am using Labview 7.1.
As far as I know, queue references are destroyed when the top level VI where the queue has been created has finished executing. This is explicit in the documentation of ''Release Queue''.
To illustrate my problem, I have attached three block diagrams. In the first VI, Queue1.vi, a queue is created and passed to the caller via an indicator. The second VI, Queue2.vi, takes a queue and does something with it (it is not important that the queue is released, any queue operation would do). As long as the top level VI is executing, everything works fine. Try it! Create a VI called QueueTestStatic.vi, insert Queue1.vi and Queue2.vi, wire them together and create an error out indicator. The VI will execute and produce no error. (I could not attach more than three files).
I need to do the same thing as in QueueTestStatic.vi, but with dynamically loaded VI:s. This is illustrated in the third VI, QueueTestDynamic.vi. When it is run, Queue1.vi is executed as a top level VI. The queue reference is passed to Queue2.vi, just as it would when you wire them together. (How the reference is passed to Queue2.vi is actually irrelevant.) When Queue2.vi is executed (top level), the queue operation fails with error code 1. Conclusion: what was possible to do with static sub-VI:s, is not possible to do with dynamically loaded VI:s.
To clairify why this is upsetting, please note the following: Labview has a garbage collection routine which destroys objects when a top level VI has finished executing, and all VI references to the top level VI has been closed. Using this knowledge, it is possible to run dynamically loaded VI:s (they will run top level) and to keep the reference to the VI open to prevent the garbage collector to kill everything created in the VI. As you can see, I attempted to use this feature to preserve the queue.
But it does not work with queues. Queues does not obey the normal rules of garbage collection. Instead, they seem to be destructed the moment Queue1.vi has finished executing. As you can see in the documentation of ''Release Queue'', this behavior could also be expected. But it is wrong. In a sound programming language, each approach (static or dynamic) would work just the same, without the need to make assumptions about the loaded VI containing queues or not. (Or an object of type xyz for that matter.)
In my projct, I cannot make assumptions on the implementation of the loaded VI:s (e.g I cannot restrict the uses of language primitives) and I cannot radically change the implementation in the loaded VI:s (since they belong to other projects). What I do need is the ability to choose to execute the VI:s dynamically or statically, without this decision affecting the result of the algorithms.
As I am unable to tell you more about the project I am working on, if you fail to see the possible applications of the dynamic approach, I am truely sorry. At least I hope that I made the theoretical motivation clear. I would like the language to behave in a consistent and predictable way. Why should queues be treated differently? Why not use one mechanism for all language primitives? The only difference is a small, but important condition (the italic text above).
Oh, and did I forget to tell you that my project dropped dead the instant I discovered why the annoying error occured?
Thank you millions for trying...
/Patrick