Modifying cluster values via refnum/property node freezes VI on quit
I just learned how to use property nodes and refnums to modify the values of individual controls inside of a type-defined cluster. But when I incorporate this into an existing and working VI, a weird thing happens: the VI works exactly as it should when it is running, but when I quit the VI, the VI freezes Labview, i.e. Labview will not respond to anything besides a force quit. Sometimes the freeze is temporary and Labview regains responsiveness; other times i have to force quit. when i use the debugger, it shows that all code has finished executing before the freeze. This VI uses serial commands, but all connections are closed correctly. an important detail may be that on my panel I have a cluster ("A") of type-def'd clusters ("B"). So I'm using a property node of the top-level cluster A to get the refnums of the clusters B1 and B2 inside, then I use the "to more specific class" function to specify the type of those clusters B1 and B2. I then feed one of those refnums into a property node and set/get the values for specific controls inside either clusters B1 or B2. If this is more complex than it has to be, please let me know. Some of the Labview documentation seems to imply that what I am doing with modifying nested cluster controls is not the greatest idea, but i don't know if that's why my VI freezes. Like I said, I'm just learning this aspect of LabView,so I don't know if I'm supposed to take into account things like closing off references, memory leaks, or garbage collection (my formal programming training consisted of C and Java). I would appreciate any insight you may have. Thanks.
Re: Modifying cluster values via refnum/property node freezes VI on quit
You can create reference for individual element in the cluster explicitly. To do so, right click on an element inside the cluster, goto "Create >> Reference". See if this helps. -Joe
Re: Modifying cluster values via refnum/property node freezes VI on quit
Thanks for the feedback, Joe. I tried using references to the individual clusters B1 and B2, but that did not alleviate the problem. Though I still do not understand why I am having this problem, I have (somewhat) isolated the source of the problem to the following location: my main VI has a loop that runs every 500 ms or so. Inside the loop, I have a sub-VI that takes one of the cluster B references as a wired input. Inside this subVI, i use asynchronous property nodes to change a value inside the referred cluster. If I remove all property nodes from this sub-VI and keep everything else the same, the VI runs and quits flawlessly. But if I place a property node inside the sub-VI, then the VI takes a long time to quit. This phenomenon is the same even if that property node is not connected to anything external and refers only to a control local to the sub-VI's panel. I have reproduced this problem on multiple computers, and I'm starting to believe that, unless I am doing something really stupid, that this is a flaw in LabView 6.1's memory management. In other words, if there's some sort of small memory leak or delayed garbage colleciton associated with using property nodes, it is magnified by using them repeatedly. If someone knows if LabView 7 fixes this problem, please let me know. Below are further observations that are further evidence for my hypothesis: - the longer the main VI runs and the loop repeats, the longer LabView takes to recover responsiveness after it freezes on quit. - if other VI's are running at the same time, after a while, their loops start to become laggy. - even though all open windows of LabView freeze when i try to quit this VI, the other VI's still continue running fine in the background. I know this because a PID loop running in a separate VI was still maintaining flawless PID control, even though its front panel was frozen. anyway, if anyone knows how to fix this problem, I would be extremely grateful. - emory
Re: Modifying cluster values via refnum/property node freezes VI on quit
So it turns out that I am making a common mistake and that, had i done a little more research before posting this question, I would have found my solution in the huge debate about CLOSING REFERENCES. Anyway, the short answer to my own question is that I needed to close all references that were not direct references to front panel objects (that would be only Cluster A in my terminology). All other references generated by property nodes (such as Controls[]) should have been closed when I was done with them. When I closed them, my VI ran and quit perfectly and the problem was gone. It turns out my suspicions about garbage collection and memory leaks were pretty much on the money, especially re: using property nodes in loops. I'm not going to rehash everything that has already been discussed, but for people who stumble upon this thread first and want to know more, here are some general tips and links: - close all references when you're done with them - it doesn't matter if you close references to front panel controls -- nothing happens. - opening property nodes inside of loops that repeat many times is a bad idea, unless you close ALL of the generated references in each loop iteration (including each of the Controls[] elements). This is because (in LabView 6), a new reference is generated each time you call the node. If you don't close it, LabView will stockpile all the references in memory and take a long time closing them when you quit your VI. - These problems apply to LabView 6.0 and 6.1. LabView 7 apparently does not have this problem because it doesn't generate new references for each loop -- it gives you the same ones each time. - The examples that National Instruments gives you in the tutorials are MISLEADING! The examples do not close references. Yeah, yeah, I know NI wants you to upgrade to LabView 7, but not everyone wants to plunk down a few G's for a fix that should be free, so NI should really emphasize closing references til the cows come home in their instructional material and help files. useful links for better explanation: http://www.ni.com/devzone/lvzone/dr_vi_archived4.htm http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=4&HrefOffset=#HowDoIFormatHTML thanks to Joe for responding to my question. - e
Re: Modifying cluster values via refnum/property node freezes VI on quit
whoops, that second link is not right. here's the correct one: http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000800834C&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=closing+references&USEARCHCONTEXT_QUESTION_S=0
Re: Modifying cluster values via refnum/property node freezes VI on quit
It might worth to try to close the reference after each loop. Creating a reference is an expensive (CPU cycles) operation. If the reference is closed, labview will close them when closing the VI, so, the longer it runs, the longer it takes to clean the memory. -Joe
Re: Modifying cluster values via refnum/property node freezes VI on quit
sorry, only after posting my comment did I noticed your own response. You got it! -Joe