Preallocating Arrays for Deterministic Loops
Figure 1 shows an example of a method that induces jitter. Because the Build Array node inside the WHILE loop uses the memory manager, a shared resource, this example induces jitter, especially if there are parallel normal priority VIs running that also use the memory manager.
Figure 1. Bad Example: While loop using Build Array.
Figure 2 shows an example of a method that reduced jitter. Because the WHILE loop uses a Replace Array Subset node to create the output array, this example does not use the memory manager because the array has been preallocated.
Figure 2. Good Example: While loop using Replace Array Subset.
Look inside all of the subVIs that are inside of your time-critical loop to make sure that no memory management occurs inside of them. Even if you build an array with only one element in it, the memory manager still is used. You also need to preallocate an array with only one element.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
