Jump to content
Neil Pate

Memory leak when attempting to set cluster elements by name

Recommended Posts

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.

Memory Leak.PNG

Share this post


Link to post
Share on other sites

LabVIEW bug would be my guess, as I don’t think those OpenG VIs use any references.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Variant.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.