LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Preventing buffer allocation for subVI controls

Solved!
Go to solution

When using the "Show Buffer Allocations" tool, I notice that memory seems to always be allocated for all controls. In another post I read that these buffer allocation dots only indicate that memory 'may' be allocated. I'm wondering if there is a way of knowing for sure if this is the case.

 

For example, can I assume that if a VI is called by another VI, and the subVI has a control that is tied to a terminal, and that terminal is wired up in the calling VI, then there definitely would not be a new buffer created?

 

In particular I am looking at the Actor Core, and wondering if I should be concerned with the amount of data used to define the Actor class. When processing messages both the Receive Msg VI and the Do VI show buffer allocation for the actor control (see attached). There really is no reason to, so I'm assuming that the compiler will not actually create new buffers, and that the actor occupies the same location in memory throughout the Actor Core loop. 

 

I was planning to use a Functional Global to hold a lot of data for reference, to ensure that it remains in the same location in memory, however would be much nicer to add this data to the actor class. But if the actor is going to be copied each time through the actor core loop, I’m better off using the FGV.

 

Thanks,

John

0 Kudos
Message 1 of 6
(3,253 Views)

Hello John,

 

I suggest using the memory usage monitors available with your operating system. Run your VI and then try the following: Right click on an empty area of your taskbar at the bottom of your window. Select "Start Task Manager" and then select performance. If the memory usage is constant this would suggest that it is not reallocating memory each time through.

 

Also, you can read over this document: http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/vi_memory_usage/

 

The section titled "SubVIs Can Reuse Data Memory" suggests that memory is not reallocated as long as it refers to the same original front panel objects.

Message 2 of 6
(3,186 Views)

Hi Meekshow,

 

Thanks for this info. Planning to test as you suggest, but haven't got to it yet. Based on that document it doesn't look like it should be a problem, though unfortunatly can't say for certain. Document is still quite vague stating "In General" it happens this way. Wish there was some way of knowing for certain, based on compiler rules, how memory will be alocated during a sub VI call. 

 

John

0 Kudos
Message 3 of 6
(3,129 Views)
Solution
Accepted by JohnG3k

Look at the buffer allocations in the calling VI, not in the subVI. If you don't see buffer allocations on the subVI terminals, then the inputs are reused in the subVI (with the exception that if the subVI's front panel is open, there's a copy made to display to the user). That said, there may be cases where you do see a buffer allocation but one isn't always done, so the buffer allocation dots will show you that no buffer is allocated, but not that one definitely is allocated.

Message 4 of 6
(3,120 Views)

Great! Suppose I still don't know for sure that another buffer won't be created, as there are always dots on the controls, but I will assume then that as long as I don't open the FP or use local variables or property nodes, etc. then I can ignore those dots. So in my case, should be no buffer allocations (except the first one) as there are no dots on the calling VI.

 

Thanks,

John

0 Kudos
Message 5 of 6
(3,110 Views)

The buffer allocations you're seeing on controls in the subVI apply only when you run that subVI as a top-level VI, because in that case, there's no input buffer to reuse. You'll always see buffers allocated for top-level controls. That's why you need to look at in in the full context of how the subVI is called.

0 Kudos
Message 6 of 6
(3,103 Views)