From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calling by reference dialog

I understand that using invoke node or calling by reference node to call a Vi will save memory, since the VI called is only load into memory when needed, and it is released from memory when its reference is closed.  The memory referred is RAM, right?  In this case, why drop any subvi directly into the block diagarm?  Why not just call everything by reference?  i am thinking about calling all my dialog VIs through calling by reference. What are the pros and cons on that?  Usually, what are the good candidate for calling things by reference.  I understand that using the invoke node, I can call a VI as a daemon, but not sure about all the pros for calling by reference

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 4
(2,204 Views)

Theoretically you probably could run everything in the program dynamically. The problem is execution speed. Before every call, LV would have to load into memory the code you want to execute, and then after every call deallocate the memory associated with it - this would make any non-trivial program very, very, very slow.

 

Still there are a few place where the trade off works. Say for example that you have an initialization routine that may only run one time - ever. That would be a place to use the dynamic loading and execution. Or say you have an application where you want to define a structure that utilizes a plugin architecture to make the program more adaptable, this would also be a good place to use dynamic loading. Dialog boxes are another place where dynamic loading can be used to good effect.

 

Mike...


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 4
(2,197 Views)

What modern hardware and operating system are you using that is so short on RAM that you can't spare a couple of kb for your subVIs?

 

Seriously, calling everything dynamically would be a terrible idea. On modern machines there's plenty of RAM and processors are fast but disk drives are slow, so having to constantly load subVIs off disk would slow your program enormously. If you really run low on memory the operating system will use "virtual memory" - disk spaced used as RAM - to hold memory pages that aren't actively in use, so trying to minimize RAM use shouldn't be a concern.

 

I don't even agree that a one-time use VI that temporarily needs a lot of RAM is a good candidate to run dynamically - I'd just throw the "Request Deallocation" node in it (not that I've ever actually needed to do that, though). Calling by reference is most useful when you don't know at compile time which of several VIs you will need to run, or how many copies of it you will need have running concurrently.

 

Unless you have a really good reason for doing so, don't fight LabVIEW, and the operating system, on memory management.

Message 3 of 4
(2,186 Views)

Well said Nathan!

 

Yes there are some times it is desirable to call by reference.  ACBR, When you programaticly determine a plug-in, When you need access to a specific clone instance, When you want to change some flags of the vi (editing a VIT for example).  But these are rare cases.  If you are conserned with start-up time (Loading lots of dependancies in large projects) use a splash screen effect to bury the load time.  Most large apps follow the splash while opening and your uses will seldom complain.


"Should be" isn't "Is" -Jay
Message 4 of 4
(2,174 Views)