LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Do control references cause memory leak?

Hi

 

I'm confused about this question for a long time.

1. If there are some controls in the front panel, and I create a lot of control reference in the block panel, should I close the control references after I've used them?

20200604001.png
I think it is not necessary to do it since I've never seen someone did it.

 

2. If I get the control references from the elements inside the cluster or other controls, should I close the control references after I've used them?

I think it is not necessary to do it, but I see someone did it...

20200604002.png

 

3. If I pass the control reference to a subVI, should I close the control references inside the subVI after I've used them?
I think it is not necessary to do it since I've never seen someone did it.

20200604003.png

20200604004.png

 

I think this is a basic question, but I still can't make it clear.

My understanding is that when I create control references of a specific control, they points to the same control in the front panel.
It should not lead to memory leak since the control references are statically exist in the block diagram.
I don't need to close them, LabVIEW will handle it for me at last.

Is my understand true?

Message 1 of 10
(3,224 Views)

You are correct.  You don't need to explicitly close control refs, and for the exact reasons that you think.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 2 of 10
(3,189 Views)

For more details: Closing References in LabVIEW 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 10
(3,159 Views)

Question for the OP:

 

Why are all of your Close References inside a single pane Flat Sequence?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 10
(3,119 Views)

Hi RTSLVU,

 

I'd just like to emphasize "the action of close reference"...
I'm sorry to make you confused, maybe I should use decoration instead 😂

0 Kudos
Message 5 of 10
(3,098 Views)

It's not confusing, it's redundant... or rather superfluous. 

 

Think about the data flow.

 

And yes you should use a decoration for emphasis not a programming structure

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 10
(3,091 Views)

Hi billko

 

Very thanks for your reply.
I've seen many students and engineers put "close reference" for the control references(especially like the second case of my original post) or object references(like panel, pane, decoration, ...).

That confuses me for a long time 🤔
By the way, one of paragraph from the link crossrulz shared also confuses me a little:
20200605002.PNG

I thought the panel reference array is not necessary to be closed manually, the elements of the reference array should be the same...

0 Kudos
Message 7 of 10
(3,087 Views)

Hi crossrulz,

 

Very thanks your help!

There is a paragraph, however, confused me a little.

20200605001.PNG

 

It said reference leak happened to control reference as well.

I hardly imagine how to make it come true.

I have two question:

1.

I thought reference memory leak happened when LabVIEW loses the access of the reference and has no chance to close it anymore or when the references is populating unintentionally.

For control reference, LabVIEW handles it totally, it can close it absolutely. 

And the control references may be distributed in the VIs in a project, they are static and determined, is it not possible to populate unintentionally?

2.

If the reference memory leak still happened, does the increased memory just come from the new RefNums, not the related data?
For example, if there is an array occupied with 100MB, and the control reference of that array leaks, Is the memory leak like this way: 100MB + 2 byte + 2 byte + 2 byte + ...(a RefNum occupies 2 byte memory)

I hope my thought is not too wield and goes too far 😅

0 Kudos
Message 8 of 10
(3,075 Views)

@William1225 wrote:

Hi crossrulz,

 

Very thanks your help!

There is a paragraph, however, confused me a little.

20200605001.PNG

 

It said reference leak happened to control reference as well.

I hardly imagine how to make it come true.

I have two question:

1.

I thought reference memory leak happened when LabVIEW loses the access of the reference and has no chance to close it anymore or when the references is populating unintentionally.

For control reference, LabVIEW handles it totally, it can close it absolutely. 

And the control references may be distributed in the VIs in a project, they are static and determined, is it not possible to populate unintentionally?

2.

If the reference memory leak still happened, does the increased memory just come from the new RefNums, not the related data?
For example, if there is an array occupied with 100MB, and the control reference of that array leaks, Is the memory leak like this way: 100MB + 2 byte + 2 byte + 2 byte + ...(a RefNum occupies 2 byte memory)

I hope my thought is not too wield and goes too far 😅


This the opposite of what you're thinking.  This is actually very thought-provoking.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 10
(3,048 Views)

It seems that if I put XControl references into an array which is going to be input for TestStand Event Callback vi, indexing array and using reference causes memory leak.

 

I wonder, if indexing references from array (in subvi) makes a copy of a reference, or is it because Event Callback seems to be executed in a kind of different memory space (at leat breakpoints and normal debugging does not work) or a combination of those two?

 

Or should I always close an XControl reference, when it is indexed from an array?

0 Kudos
Message 10 of 10
(1,842 Views)