How do you avoid unneccesary "array copies"?

Hello - I have been having significant difficulty trying to optimize my code as I have been finding that LabView tends to make copies of variables almost everytime you access them. This may not be a big deal some times, but in my case, I am using arrays that are 10MB in size or greater, and making duplicates of them not only wastes memory, but also time. I would like to figure out a way to avoid this. From what I can see, using a continuous thread with shift registers and sequence locals can reduce some of the duplication, but generally that becomes a wiring nightmare in the diagram. Also, one thing that I would like to do is keep some of these arrays within a record format, but I think anytime you have a wire coming out of a
bundle, a new copy of that variable is made. I'd like to be able to use pointers, but someone from NI told me pointers were a "bad word" in LabView and references obviously don't work the same.
Any ideas would be appreciated (sorry the text is long).

> I have read that document, and especially in terms of the
> bundling/unbundling, it more or less just states to avoid it which for
> my application may not be the easiest solution. Also, in it a phrase
> reads "Each level of unbundling/indexing might result in a copy of
> that data being generated". I'm trying to figure out when "might"
> becomes "does" or "doesn't". Also, I have seen the consequences of
> using locals, globals and "value" property nodes. I wonder why LabView
> requires making a copy when these are used (because programatically
> within the scope of the diagram they are much easier to use then
> sequence locals and shift registers). thanks.
First, I'll comment on the local and value property. If the AE really
said that pointers are a dirty word in LabVIEW, what they really meant
was that LabVIEW works on dataflow and really doesn't expose the pointers.
The upside of this is that it is much less likely that you will have
uninitialized values, stale pointers, memory leaks, etc. You also have
much clearer idea of what is happening to your data, and parallelism is
much easier to see/use. The downside is that you have less control.
Also, it is best not to think of the reference as a pointer/reference to
data, but instead it is a reference to a UI object, the control or
indicator.
Locals and reference->value are convenient when you are used to writing
lines of code, or expressions that move the data from one location to
another. This code is typically using a sequence to make lines of code
where each of them loads what it needs, modifies it, then stores the
results. Again, this feels familiar, but it is not what works well in
dataflow like LV. It works much better to largely get rid of the
sequences and simply let the data dependency do the work.
Doing this should automatically help your memory usage provided you keep
the items in the performance chapter in the back of your mind. Also,
remember that subVIs normally don't hurt memory usage provided their
panel is not open, and they can even help with memory usage as storage
buffers can be reused.
For the unbundle issue, hopefully your have an array of rather small
records, but in the event you have a record with large arrays, you do
need to avoid repeatedly accessing the elements, indexing, etc. You may
want to build a data access subVI that can do the indexing, searching,
etc in a common location and avoid returning the big arrays. This also
allows for the storage to be moved to a shift register and the whole
thing becomes a functional global.
You might want to spend a little time browsing through the examples for
smart or functional globals as well as some of the analysis ones that
process arrays to see how they deal with the sequencing and wiring.
Greg McKaskle

Similar Messages

  • How do you make an array of image icons and then call them?

    How do you make an array of image icons and then call them, i have searched all over the internet for making an array of icons, but i have
    found nothing. Below is my attempt at making an array of icons, but i cant seem to make it work. Basically, i want the image to match the value of the roll of the dice (rollVal)
    Any help would be greatly appreciated, some code or link to tuturial, ect.
    /** DiceRoller.java
    * Roll, print, Gui
    import javax.swing.*;
    public class DiceRoller extends JFrame
         private ImageIcon[] image  ;
         public String[] images = { "empty", "dice1.jpg",
                   "dice2.jpg", "dice3.jpg", "dice4.jpg",
                   "dice5.jpg", "dice6.jpg" };
         public Dice die;
         private int rollVal;
         public int rollNum;
         private JLabel j1;
         public DiceRoller(){
              j1= new JLabel("");
           die =new Dice();
           int rollVal;
           rollVal = die.roll();     
           image = new  ImageIcon[images.length];
         for(int i = 0; i < images.length; i++){
          image[i] = new ImageIcon(images);
         if (image!=null){
              j1.setIcon(image[rollVal]);
         System.out.println("Roll = "+die.roll());

    Demo:
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class IconExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch();
        static void launch() {
            try {
                Icon[] icons = new Icon[6];
                for(int i=0; i<icons.length; ++i) {
                    String url = "http://www.eureka-puzzle.be/cast/images/dice" + (i + 1) + ".jpg";
                    icons[i] = new ImageIcon(new URL(url));
                display(icons);
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
        static void display(Icon[] icons) {
            JPanel cp = new JPanel();
            for(Icon icon : icons) {
                cp.add(new JLabel(icon));
            JFrame f = new JFrame();
            f.setContentPane(cp);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • With the new Iphone update, how do you avoid Facebook syncing your friends into your contacts?

    With the new Iphone update, how do you avoid Facebook syncing your friends list with your contacts??

    The iphone will sync itunes content with one computer at a time.  If you sync to another it will erase the current content from the iphone and repalce with content from the new computer.

  • When syncing 2 iphones to itunes how do you avoid getting each others apps

    When you sync 2 iphones to itunes how do you avoid
    getting each others apps

    For some reason without syncing
    when I download an app the 2 phones
    get the same app. They are 2 different
    phones with 2 different apple IDs

  • How do you create an array of any size(no limits).

    how do you create an array of any size(no limits). this array should hold BigInteger values.
    BigInteger[] array = new BigInteger[100000000]; //creates new array of BigIntegers array[0] = new BigInteger("6"); //puts "6" in
    array[1] = BigInteger.ZERO;
    but this type of an array can only hold a limited amount.

    Use a java.util.List, e.g., ArrayList or LinkedList.

  • HT201270 How do you avoid timed-out?

    1.Where are the updates stored?
    2. How to you avoid timed-out session if you don't have wifi access?

    I suspect it has something to do with your network settings on your PC. I'd recommend calling AppleCare right away. you have 90 days of free AppleCare telelphone support, they can help walk you through the process. Also if you haven't already i'd strongly recommend Pondini's guide to using Migration Assistant. You can locate it by clicking:
    http://www.pondini.org/OSX/Setup.html

  • How do you create an array without using a shell on the FP?

    I want to be able to read the status of front panel controls (value, control box selection, etc.) and save it to a file, as a "configuration" file -- then be able to load it and have all the controls set to the same states as were saved in the file. I was thinking an array would be a way to do this, as I have done that in VB. (Saving it as a text file, then reading lines back into the array when the file is read and point the control(s) values/states to the corresponding array element.
    So how do I create an array of X dimensions without using a shell on the front panel? Or can someone suggest a better way to accomplish what I am after? (Datalogging doesn't allow for saving the status by a filename, so I
    do not want to go that route.)

    Thanks so much m3nth! This definitely looks like what I was wanting... just not really knowing how to get there.
    I'm not sure I follow all the icons. Is that an array (top left with 0 constant) in the top example? And if so, that gets back to part of my original question of how to create an array without using a shell on the FP. Do I follow your diagram correctly?
    If I seem a tad green... well I am.
    I hope you understand the LabVIEW environment and icons are still very new to me.
    Also, I had a response from an NI app. engineer about this problem. He sent me a couple of VI's that he threw together approaching this by using Keys. (I still think you are pointing to the best solution.) I assume he wouldn't mind m
    e posting his reply and the VI's for the sake of a good, thorough, Roundtable discussion. So here are his comments with VI's attached:
    "I was implementing this exact functionality this morning for an application I'm working on. I only have five controls I want to save, but they are all of different data types. I simply wrote a key for each control, and read back that key on initialization. I simply passed in property node values to the save VI at the end, and passed the values out to property nodes at
    the beginning. I've attached my initialize and save VI's for you to view. If you have so many controls that this would not be feasible, you may want to look into clustering the controls and saving the cluster as a datalog file.
    Attachments:
    Initialize_Settings.vi ‏55 KB
    Save_Settings.vi ‏52 KB

  • How do you make double sided copies?

    i have laser jet pro cm 1415 fnw color mfp
    how do i make double sided copies,? from double sided paper, and from one sided paper?

    Hello,
    Thanks for the post.  With this model you do have the ability to manual duplex.  I've attached a document below with the steps to walk through this process.  Good Luck!
    http://h10025.www1.hp.com/ewfrf/wc/document?docnam​e=c02244601&tmp_task=useCategory&cc=us&dlc=en&lang​...
    I worked for HP but my posts and replies are my own....Thank you!
    *Say thanks by clicking the *Kudos!* which is on the left*
    *Make it easier for other people to find solutions, by marking my answer with (Accept as Solution) if it solves your issue.*

  • How do you avoid filling in details for checkout in loggedin

    hi, hope someone can help me here... if a user is logged in, how do you have them checkout without filling in the checkout form?

    You can edit the checkout forms to include that information.  Certain BC modules will work when a user is logged in.
    For your checkout form, you need to edit the HTML and add a module to the "value" attribute on the "input" elements you want prefilled.  If you have an input for a name:
    <input type="text' name="name" value=""/>
    You just need to include the module that outputs a logged in user's name:
    <input type="text" name="name" value="{module_fullname}"/>
    The list of available modules for use with secure zones is located at: http://helpx.adobe.com/business-catalyst/kb/modules-quick-reference.html#Secure-zones

  • How  can you avoid that an ABAB-Function works with an  EXPORT_PARAMETER

    Hello everybody,
    I have to call the ABAP-Function ECATT_EXECUTE via JCO.
    In SAP 7.0 there is a new EXPORT_PARAMETER for the function ECATT_EXECUTE, which is called E_RESULT_XML.
    There is a statement "IF E_RESULT_XML is requested" which gives always TRUE, so that the function tried to fill this Parmeter and an error occurred while processing.
    How you can avoid this ?
    What you can do, that this IF-Statement gives FALSE ?
    Every helpful hint is welcome !

    Hi Klaus,
    It may be because when calling a function via JCO all import/export/table parameters are always passed with the call.  Have you tried running the function from a test ABAP program and NOT requesting the parameter E_RESULT_XML?  If that works ok, the simple solution is to create a custom wrapper function module that you can call from JCO, which will call ECATT_EXECUTE for you ignoring E_RESULT_XML and then return the results to your Java.
    Hope this helps,
    Gareth.

  • How do you pass an array of characters using the DLL functions

    I have exported C code into my DLL and I want to know how to pass an array of characters using LabVIEW.

    Mont;
    If you want to pass a string from LabVIEW to your dll, and you do NOT change size of the string, you can use a C String pointer (CStr), which is equivalent to (unsigned) char *.
    If you do modify size of the string, pass string as a LabVIEW structure (LStrHandle).
    The example "Passing a Variety of Data Types from DLL to LabVIEW" is an excellent starting point. Also make sure you check the manual "Using External Code in LabVIEW".
    Regards;
    Enrique
    www.vartortech.com

  • How do you avoid startup messages?

    Hi, I've currently had to change the RAM on my Elitebook and it's popping up the screen during startup saying it's incompatible and that i'm to press enter if I want to continue. I know the problem is due to a different voltage but for now this has to function as it is at least for now. How do I get my laptop to stop prompting me with that screen every time I restart it? It's not because I'm too impatient to press [Enter] but simply cos I have to use it at work and I really need to avoid them asking a bunch of questions why that screen is showing up etc. Can you help please???

        [email protected]
    Let's get this figured out! When you say forwarding are you just trying to forward the same context to another contact? Or are you trying to have all of your text forward to another device? Have you ever been able to forward text messages? Is this only when you try to forward media of also regular text messages? Please provide additional detail so we can resolve this issue.
    JorgeO_VZW
    Follow us on Twitter @VZWSupport

  • How do you avoid screwing with other vendors' Plug-In requirements?

    I can control which plug-in my applet uses pretty easily by using the correct info within the HTML page that calls it.
    What if another vendor, though, is not requesting a specific plug-in version in their html ... but uses the browser default instead?
    When I upgrade my applet to another plug-in version and update my HTML to reference the new version, won't that change the browser's default at download/install time?
    Is there a way that I can say:
    1. Use this particular plug-in version.
    2. If not found, install it -- but don't mark to set the new plug-in as any browser default?
    3. If the install can be done silently, is their a silent method that works for Windows and Mac and for IE, Netscape, and Safari?
    In other words for the same customer, if Vendor A needs plug-in 1.2, Vendor B needs plug-in 1.3, and I need plug-in 1.4, how can these all live happily together?
    Is the only way to do this to make sure all vendors are using the same plug-in strategy?
    Thanks.

    Hi Swett,
    for silent installation you can check out
    http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/silent.html
    The method described there by default does not register the plugin to be the browser's default. I haven't actually tried silent install myself, though, and don't know on which systems it'll work.
    Regarding other vendor's plugins: I'm afraid there's no guarantee you don't mess up anything. I guess that if everyone is using static plugin versions in their html then they can live next to each other without interfering, the problem comes into play if someone uses dynamic version control. That is what actually happened to me, having deployed an applet requiring jpi 1.3.1 or higher, and later had to find out that it didn't work for clients once they'd installed 1.4 on top of it :-(
    In principle I would prefer dynamic version support since it minimizes the number of plugins clients have to install, but due to the ever changing plugin features (grrr...) static version support is probably the recommended way to go (if your customer finds that acceptable).
    The lesson I had learned from that is that in the end each vendor and each customer is responsible to have a robust plugin/html deployment, and the client is responsible not to mess up his system (by e.g. having one plugin to be the browser's default) -- all you can do is offer your advice to both parties.
    Cheers,
    Gerret

  • How do you remove iOS8 update. How do you avoid using iCloud

    How do I remove iOS 8 update? it is locking up my phone because I do not want iCloud.

    There is no support for downgrading. If you don't want to use iCloud, then delete your iCloud account from the phone.

  • How do you avoid double-click

    When running flash on a web page you usually have to click
    the Flash object once and then once again to click a button.
    Is there a way to avoid this because many users are missing
    the second click and wondering why nothing is happening.
    Or, am I missing something very simple?
    Regards
    Dave

    Most likely you are talking about
    Eolas Patent impact
    on IE.
    In repsonse to Eolas, Microsoft has made changes to Internet
    Explorer browser that impact the use embedded ("active") content
    such as that viewed in Adobe's Macromedia Flash Player, Authorware
    Player, Shockwave Player, and Adobe Reader, as well as Sun Java,
    Apple QuickTime, and RealNetworks RealPlayer.
    This includes the need to click to activate.
    Adobe maintains a page that provides what you need for all
    their products:
    Adobe Active
    Content Development Center

Maybe you are looking for

  • Creation of SAP Table in SE11

    Hi! I am facing with the problem of hanging SPAM patch (SAPKB13 - 16). The patch will be stopped in the phase IMPORT_PROPER (step: DDIC activation) after few seconds. The error is: SPAM IMPORT_PROPER Reason: TP_STEP_FAILURE Return-code: 0008 Error me

  • Moving print queues

    We are preparing to move from queue based printing to iPrint and are experiencing the following problem with Windows XP locked-down workstations. We created the queue directory on the iprint server, gave the ou rights to the queues directory, changed

  • Vendor creation

    Vendor is having different locations and accordingly they are supplying materials, but in the vendor master we want to maintain master data with single location only as a policy decision. Example: we are maintaing vendors "X" plant details in the ven

  • Instead of Compressor went Quicktime conversion (still problems)

    Hi, Thanx for all the suggestions regarding compressor. I didn't even consider doing Quicktime conversion for my DVDSP2. I did this last night with a two pass knowing it would take along time. After about 9 hours with some 18 to go ( the piece is 78

  • REVERSE ENGINEERING SOAP XML TO SVO

    Hi We are using Oracle Integration Repository for webservices development . We have following soap xml . That soap xml needs to be processed by a webservice . For that I believe we have to generate the SVOs and AM looking at the SOAP xml . But my onl