Subject: Re: [M]LV3 Memory management
From: Greg McKaskle gam@natinst.com
Date: Fri, 2 Dec 1994 10:38:40 -0600


References: <3bk9qg$b36@natinst.com>
Organization: National Instruments

> My application deals with large signal records (>200000 [I16] samples).
> Using general modular conception and dataflow sequencing conduct to isolate
> specific tasks in subVIs.
>
...
> I meet frequent memory problems (bulldozer comes up).
>
> I don't really understand how LV3 uses memory.
>
...
> Q3- what can we think about the principles of modularity and dataflow
> sequencing when we are faced to memory problems ?
> Is it better to use Sequence structures and put all the stuff in the same
> VI (no modularity, no dataflow sequencing) ?
>

Absolutely not. Well designed subVIs that allow the data to flow through
them are the best way to minimize copies of your data buffers. If
operations don't need to be run in parallel, place them one after the
other, and pass the data through the operation if possible.

If you start programming your operations in separate frames of
a sequence, you will soon be using many times more memory than
you are now because you will start using globals and locals to
simplify your wiring.


> Q4- Using GLOBALS could solve memory problems ?
>

Globals, especially the built-in globals, are convenient to use, they
are the best way to share information between parallel loops, but
they will cause extra copies of your data buffers so that they can
be protected from multiple writers.

Only use globals to share data between parallel loops. If after
reading the global, you commonly index an element out, or if
you commonly reduce the data that you really need, you
might consider writing a LV2 style global that stores its data
in an uninitialized shift register and has programmatic access
to its global data. This subVI can perform "smart" reads
where it returns only the information that you need, not the
entire buffer of data.

> Q5- What is the memory allocation strategy for GOBALS and LOCALS ?
>

When a global or a local are read, they create a copy the data to put on
the signal. They do this because the global can be written to at almost
any time. The read operation is protected; so the read will never be
interrupted by a write, but it isn't possible to protect the global for
other diagram operations because that would introduce deadlock
possibilities.

TheLV2 style global can only be accessed by a subVI call. Therefore
the data in the subVI loop's shift register is protected by the subVI
call mechanism.

> Thanks in advance for your help.
> ----------------------------------
> Jean Pierre Poindessault
> CNRS, URA 1869, L.B.S.C
> 86022 Poitiers Cedex, France
> Phone: (33) 49 45 36 38
> E-mail: JPP@hermes.univ-poitiers.fr
> ------------------------------------