LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is memory allocated for "string subset"?

Is memory allocated when using a "string subset", or when using an "array subset"?  I'm trying to avoid memory allocation for a Labview RT project.
0 Kudos
Message 1 of 2
(2,527 Views)

The answer may depend on whether the array wire coming into the "subset" function terminates there or whether it branches elsewhere.  If it terminates, there's a chance that new memory needn't be allocated, though I can't say for sure that it won't.  Some versions of LabVIEW have a menu option to "Show Buffer Allocations", but it seems that I've seen comments on these forums suggesting that those buffer allocation indicators aren't 100% accurate.  On the other hand, if the array wire branches elsewhere it's at least very likely that you'll be allocating memory.

Can you describe a bit more about your app, your array and subset sizes, loop rate requirements, etc.?  Sometimes you can rewrite your processing algorithms in ways that avoid memory allocation, though it can take a bit of work.

Example:  suppose you want to take the same size array subset every RT loop.  You could instead create a shift register on the loop to hold the array subset contents.  On each iteration of the loop, you pass both the original full array and the shift register subset array into an inner loop.  The subset array should go in through a shift register while the full array can go in via shift register or tunnel (it shouldn't matter).  Inside the inner loop, you use explicit indexing to extract a value from the full array and use Replace Array Subset to put it into the subset array.  When the inner loop is done, the subset array comes out the inner loop's shift register and goes into the shift register of the outer loop.

Definitely more complicated (and I didn't even cover the one-time special case of initialization), and usually slower, but should be very determinisitic due to lack of memory allocation.  The reason this works is that the shift registers retain the data memory space between calls.

You might want to pose this kind of question on the RT board because I haven't dabbled with RT since version 6.  The "rules" may have changed.  Perhaps the memory manager can figure out how to optimize cases where the length input to Array Subset is a constant or something.

-Kevin P.

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 2
(2,523 Views)