Neil Pate Posted July 4, 2016 Report Share Posted July 4, 2016 I am currently working on a project, one component of which is a OPC-UA interface to a PLC. There are approximately 100 nodes (variables). Part of my work has been to keep in mind the next iteration of the architecture needs to be able to handle approximately an order of magnitude more nodes. Dealing with this many "variables" in LabVIEW can be painful unless some programattic techniques can be used. For debugging it is useful to see all the node values, and so I implemented the technique shown below where the name of the variable can be used to update a cluster (nested to a maximum of two levels deep). This works well. The green VIs are the OpenG Cluster access VIs. However I have virtually conclusively proven to myself that when this is built into an executable this portion of code shown below exhibits a memory leak of several kB per second. Interestingly, I use a more simple version of this technique in another portion of the project to update some GUI elements, and there is no noticeable leak. Has anybody seen this behaviour before? I have not poked too far inside the OpenG VIs, but from what I have seen they should not leak anything. Quote Link to comment
Neil Pate Posted July 4, 2016 Author Report Share Posted July 4, 2016 Interestingly, this slight modification does not appear to have any leak. LabVIEW bug? Quote Link to comment
drjdpowell Posted July 4, 2016 Report Share Posted July 4, 2016 LabVIEW bug would be my guess, as I don’t think those OpenG VIs use any references. Quote Link to comment
eberaud Posted July 4, 2016 Report Share Posted July 4, 2016 So the leak would come from the variant stored in the shift register? Quote Link to comment
Neil Pate Posted July 4, 2016 Author Report Share Posted July 4, 2016 1 hour ago, Manudelavega said: So the leak would come from the variant stored in the shift register? Something like that. If I get a chance I will see if I can create a minimum code proof of this bug so that it can be analysed further. Quote Link to comment
Popular Post hooovahh Posted July 6, 2016 Popular Post Report Share Posted July 6, 2016 Very interesting, please see if you can find a simplified example that can be submitted to NI. Storing a variant in a shift register is something I'm sure I've done plenty of times. Also I don't know if it makes things easier, but I've been moving away from OpenG functions for cluster manipulation, and choose to use the NI functions, and the Variant to Data trick. Attached is an example where a cluster is turned into an array of variants, manipulated, and then turned back into the cluster. Notice that the Get Type Information also returns the data name. Oh and if you update the cluster you need to set the Cluster size in the Array to Cluster to the right number of elements, the wire will be broken if it doesn't match. I made and XNode to do this but didn't want to add another unknown into debugging this. Of course if this is a bug in LabVIEW this won't, help. If this is a bug in LabVIEW, I'd bet adding an Always Copy inside the loop will probably fix it. 4 Quote Link to comment
Neil Pate Posted July 6, 2016 Author Report Share Posted July 6, 2016 So of course my first attempt to create a simplified version has failed spectacularly. Rock-solid memory usage... drat. Perhaps it has something to do with arrays embedded in the inner clusters. Quote Link to comment
drjdpowell Posted July 7, 2016 Report Share Posted July 7, 2016 On July 6, 2016 at 1:46 PM, hooovahh said: Oh and if you update the cluster you need to set the Cluster size in the Array to Cluster to the right number of elements, the wire will be broken if it doesn't match. I made and XNode to do this but didn't want to add another unknown into debugging this. In Messenger Library, under the Utility sub pallet, I have an "Array of Variants to Cluster” VI that will dynamically handle the number of elements (up to 100). Useful in reuse code where you don’t know the specific number of elements. Quote Link to comment
hooovahh Posted July 7, 2016 Report Share Posted July 7, 2016 2 hours ago, drjdpowell said: In Messenger Library, under the Utility sub pallet, I have an "Array of Variants to Cluster” VI that will dynamically handle the number of elements (up to 100). Useful in reuse code where you don’t know the specific number of elements. Yeah but what if you have more than 100 elements in a cluster...yeah...I'm not saying it won't happen, but if it does you probably have other issues that are more pressing. Quote Link to comment
drjdpowell Posted July 7, 2016 Report Share Posted July 7, 2016 10 minutes ago, hooovahh said: Yeah but what if you have more than 100 elements in a cluster...yeah...I'm not saying it won't happen, but if it does you probably have other issues that are more pressing. The technique works up to 255, but I have yet to summon the effort to do that many cases. Quote Link to comment
QueueYueue Posted August 3, 2016 Report Share Posted August 3, 2016 Use this snippet as your base if you need to do an arbitrary amount of cluster items. I can never remember how to do it, so I always crack open Ready Anything (from MGI's Read/Write anything) to see how we did it there. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.