LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using property node by reference in a for loop

I am using reference to change the value and property of controls and indicator contained in a cluster. I built different SubVI to make my many clusters appear and disappear, write or read values of elements in those clusters. Every thing is working fine. But! my application is CPU and memory consuming. And when I stop this application. It hang for minutes. Enough to let me consider to kill my app. I read in the knowledgebase (ID 27MDAJ2L) that using reference in a loop is memory consuming. The solution given tell to not create reference in a looping structure. And preallocate array to improve performance. Do I have to create an array containing reference to all elements in my cluster?

Also, because
my cluster doesn't contains the same type of element. I need to verify the description type of each elements. This may be my problem. But actually I don't have any alternative. Is there any other way to achieve what I want to do?

I provided an example of a VI using one of my SubVI that initialise different parameters of any element in a cluster. It reproduce the problem. Not as mush as in my application but you all will notice that it does take time before the application stop completely.

Thanks!
Download All
0 Kudos
Message 1 of 3
(3,274 Views)
In terms of your problem with using property nodes in a loop, they do not inherently use large amounts of memory--as long as they are handled properly. Unfortunately some of the examples that shipped with V6.0.2 didn't handle the properties correctly. (V6.1 I don't know about.) Specifically, these examples didn't close references that needed closing.

It sounds like this could be part of your problem. Each time the loop executes it reopens a reference and eats up a little more memory. When you quit you application, LV has to deallocate all this memory, which can take a lo-o-o-o-o-o-ng time.

I once had a memory leak from this cause that if you let the program run over night, it could take as long as 35 minutes for the program to shutdown!

If you post
your code in 6.0 format, I'd be glad to look at it...

Mike...

Oh yes, in terms of what references need closing: A good place to start is close everything when you're finished with it. According to NI, closing a reference that doesn't need it is essentially a NOP so it won't burn much time. If this fixes your problem, we can talk about which ones specifically need closing...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 3
(3,274 Views)
Thanks Mike for your fast response. I will provide you the VI in 60. I didn't though closing reference was necessary. I understand that, in any programs in C, free allocated memory is a good practice and even a must. And I though that it was handled by LabVIEW. I added a two close reference into strategic places. And it really improve the performance when I stop it. If you have any idea how to improve performance, let me know.

Again Thank you very much indeed.

Mathieu
Download All
0 Kudos
Message 3 of 3
(3,274 Views)