06-03-2020 10:01 PM
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?
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...
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.
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?
06-04-2020 12:02 AM
You are correct. You don't need to explicitly close control refs, and for the exact reasons that you think.
06-04-2020 05:28 AM
For more details: Closing References in LabVIEW
06-04-2020 10:01 AM
Question for the OP:
Why are all of your Close References inside a single pane Flat Sequence?
06-04-2020 12:45 PM
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 😂
06-04-2020 01:14 PM - edited 06-04-2020 01:15 PM
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
06-04-2020 01:29 PM - edited 06-04-2020 02:16 PM
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:
I thought the panel reference array is not necessary to be closed manually, the elements of the reference array should be the same...
06-04-2020 02:27 PM - edited 06-04-2020 02:28 PM
Hi crossrulz,
Very thanks your help!
There is a paragraph, however, confused me a little.
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 😅
06-04-2020 05:15 PM
@William1225 wrote:
Hi crossrulz,
Very thanks your help!
There is a paragraph, however, confused me a little.
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.
01-12-2022 05:08 AM
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?