Leak memory in a simple loop to save data in the table?

Hello world

I'm trying to set up a simple code to read a certain amount of data in a table at a fixed sampling rate and put these data in a local variable.  I'll put this on one OR cRIO-9073 using the scanning engine and the data comes from one NOR 9208 with a speed of approximately 250 Hz scanning, even if it is not really important at the moment.

I made this little test VI which I suspect contains a memory leak, but I'm not able to identify it.  The reason for my suspicion is that when I run the vi on a VMWare virtual machine (LabVIEW 2010 on Windows XP) it claims soon that it is short-term memory.  Of course, the problem is perhaps elsewhere, but I hope that someone more experienced with LabVIEW programming will be able to find all the bugs very easily because it is really a piece very simpel to code. :-)

I have included a copy of the VI with a screenshot to illustrate.

Regards, Martin

PS my code looks a bit awkward, so if anyone has a better solution, I'd be very happy to learn about it!

Hello Martin,

I would try a different approach to your problem. Currently you reshape your table each iteration of the loop. This means that the allocator memory of LV must find a new piece of contiguous memory each iteration of the loop. You're probably fragment your memory and so short of contiguous blocks of memory, leading to the release of messages from memory.

For these types of tasks, I recommend having an array of fixed size that you initialize outside the loop and then use the Replace table subset in the loop for updating the values. This avoids the problem of allocating memory you use in.

Alternatively, since I assume that you use the local variable to pass data to another loop, you can use a FIFO RT to manage data. A RT FIFO resembles a queue of LV, but it is designed so that you can keep determinism in your application. Set up an acquisition loop that exports data from the 9208 every 4ms in a RT FIFO. Then set up your processing loop to run at a slower pace - say every 200ms. The processing loop reads all the elements of the FIFO until it is empty every 200ms or a number of samples. The RT FIFO is fixed size, if you need to make it large enough to contain at least 200/4 = 50 samples. For more security, you should do several times bigger, maybe 200 samples. You can try different sizes of the FIFO and also to the different periods of your processing loop to your application's specifications.

Using this method you do not have to create a counter to track items, since the reading of FIFO function can tell you how many items is in the FIFO and also when it is empty.

I recommend you the example of Communication of FIFO of RT which comes with LabVIEW to get an idea of how to use these functions.

Gerardo

Tags: NI Hardware

Similar Questions

  • How to check the amount of memory used during execution of the program to save data in the table?

    Hi any idea how to read or check use all memory space by accumulating the table with the data?

    My program works like this: -.

    (1) values are acquired and displayed on the table

    (2) the values are acquireduring the next event and appear in the next row in the table.

    (3) and this continues...

    Please notify

    Thanks in advance

    Hi astroboy,.

    You can use 'Flatten channel' to get the size of your data.

    Mike

  • How to save data from the COM port to file?

    Hi all

    can someone tell me please how to save data from the COM port on file? I transfer 1 byte of serial port... attached is the image of the vi... very basic.

    I would like to save the data in a table... I mean, 1 data--> data--> data tab 2 tab 3rd--> tab

    and so on... can anyone help?


  • How to write a simple select query to get the data of the table as an XML.

    How to write a simple select query to get the data of the table as an XML. In the query, I'm just adding items below which i need be there in the XML document
    select '<test_tag>'||EMP_NAME||'</test_tag>','<date>'||sysdate||'</date>' 
    from temp_table where id_num BETWEEN 1 AND 10;
    I have need to add the root tag as well in the beginning and the end of < root > < / root > this xml file. Please advice if this is possible with the select query
    without using XMLGEN, XMLQUERY or any other packages built and function?

    I need to URL escapes with the UTF-8 code points that we have already achieved using the utl_http package. Please help how to do that without using the utl_http package.

    What is wrong with him?

    At present, the only way I can think of to avoid a call to UTL_HTTP. SET_BODY_CHARSET is to write your own little wrapper.
    In this way, you can specify the Boolean parameter or omit it if you choose to use named parameters:

    SQL> create or replace function my_url_escape (url in varchar2)
      2  return varchar2
      3  deterministic
      4  is
      5  begin
      6   return utl_url.escape(url, false, 'AL32UTF8');
      7  end;
      8  /
    
    Function created
    
    SQL> select my_url_escape('http://some.uri.com/param?lang=fr&text=contrôle') from dual;
    
    MY_URL_ESCAPE('HTTP://SOME.URI
    --------------------------------------------------------------------------------
    http://some.uri.com/param?lang=fr&text=contr%C3%B4le
     
    
  • How to save data in the text file of Spartan 3

    Hi all

    I would like to kindly save the data table text file or a spreadsheet on vi using fpga spartan 3e as an fpga target. Once I added all the functions related to the operation of file, it gave an error that these functions are not supported by the target device.

    could you please help me with this

    Thank you

    Rania

    Hi David,

    Thank you for posting. You use LabVIEW? If so, what version of LabVIEW FPGA do you use? You use a host VI, or any deployment of code at your target to run? The file IO VI probably won't compile to target because they are not intended to be used on your host computer. Resources and the paths of files do not exist on the target FPGA, but rather on the side of the host. I have included a link below that describes how to transfer data between the FPGA and host. I hope this helps!

    http://zone.NI.com/reference/en-XX/help/371599F-01/lvfpgaconcepts/pfi_data_transfer/

  • How to save data in the spred sheet file that is?

    Hello

    I want to save a table in the same spred sheet file I read my external device.

    here as an attachment, I enclose the vi.

    This is the example of data I want to save for example in the first column I want only numbers with no floating point.

    and remaining column is everdata, it should be the same.

    As an attachment, file name 11 is the same file that I want to, but I always get as file attachment 2,

    can you please guide me how can I get data that is displayed in the table of labview.

    Thank you much in advance.

    This code - using the Format to a string - creates a very similar to the log file output 11. You can write the string to a file with write a text file or write the string array with write to File.vi of the worksheet.  Write to File.vi of the worksheet internally converts an array of strings for what is in the string, and then wrote this text, so it makes more sense to use only write to text file. Write to Spreadsheet File.vi help will make additional copies of the data, which can become a problem if the dataset is large.

    Read the detailed help for Format string for more information on the available format codes.

    Lynn

  • Question: Table of staging to create and manipulate files, and then save it in the table

    Hello

    I wanted to create an intermediate table to import the files so that later I can manipulate records and finally to save the database.

    I had used the space reserved for this purpose, but I can't create/insert lines in there. Since it is not through an entity object.

    Anyone has an idea about this?

    You use a vo with all transition attributes and insert the data into this before saving the data to the work table.

    Timo

  • Simple procedure to insert data into a table

    Hello

    I am trying to create a simple procedure to insert the data into the emp table.

    He throws after WARNING:

    The procedure that is created with compilation errors.

    CREATE or REPLACE procedure ins_emp (empno emp.empno%type,ename emp.ename%type,deptno emp.deptno%type)

    IS

    Emp.empno%type,P_ename emp.ename%type,P_deptno emp.deptno%type P_empno;

    BEGIN

    Insert into emp values (empno, ename, deptno);

    Ins_emp END;

    And when I try to run it

    execute ins_emp(1111,'abcd',20);

    He is to launch another error:

    PLSQL - 00905:OBJECT SCOTT. INS_EMP is not valid.

    can someone help me with this procedure?

    Thank you

    Hi Frank,.

    I thank very you much for your comments.

    I have a question:

    unless the procedure or function created with compilation errors, we cannot run them right.

  • a simple way to insert data in a table

    Hello

    I need to know in a simple way on how to transfer data from one table to the other...

    First xx_inv_tab1 table has three columns col1, col2, col3 and where as the second xx_inv_tab2 table has five columns col1, col2, col3, col4 col5.

    Here col2, col3, col4 are the same columns in table1 xx_inv_tab1...

    Now I want to transfer the first data in table in second table... first column of the second table holds a sequence, followed by the first three columns of table data and followed with col4 col5 which will contain NULL values...

    In my scenario, I have 70-75 columns in my first table that I want to move to the second table including three new columns (one is the sequence with two other null values)...

    All ideas, if do us it in a simpler way, saying rather insert into xx_inv_tab2 (col1, col2, col3, col75) values (seq, col1, col2,... col75, null, null)


    Help appreciated...

    Thank you

    Easy

    not tested

    insert into xx_inv_tab2 t2 (col1,col2,col3,col4)
    select yourSequence.nextval, t1.col1, t1.col2, t1.col3
    from xx_inv_tab1 t1
    ;
    

    Note that col5 must not be used, since you want to fill with a NULL value.

    Use excel or sql developer write you a list of the column names, if you are lazy to write all the columns of 75 by yourself.

    Which might also work:

    not tested

    insert into xx_inv_tab2 t2
    select yourSequence.nextval, t1.*, null
    from xx_inv_tab1 t1
    ;
    

    Published by: Sven w. on August 31, 2012 16:41

  • Build the value of 100 mb of data in the table using the loop

    DB version: 11.2

    How can I create about 100 MB of test data in a table using minum number of records.
    If I use the below for loop. It takes 100,000 records to fill only 2 MB.
    SQL> create table a2 (mynum1 number, mynum2 number);
    
    Table created.
    
    begin
    for i in 1..100000 loop
        insert into a2 values(i,i*2);
    end loop;
    end;
    
    
    select segment_name, bytes/1024/1024 MB from dba_segments where segment_name = 'A2' AND owner='SCOTT'
    
    
    SEGMENT  BYTES/1024/1024
    -------- ---------------
    A2                     2

    Hello

    Is that what you are looking for?

    SQL> CREATE TABLE tbl1(c1 CHAR(1024));  -- ~1KB per row
    
    Table created.
    
    Elapsed: 00:00:00.00
    SQL> INSERT /*+ APPEND */ INTO tbl1 SELECT 'X' FROM dual CONNECT BY LEVEL < 100000; -- 100K rows * 1KB = 100MB + some additional overhead
    
    99999 rows created.
    
    Elapsed: 00:00:13.02
    SQL> SELECT bytes/1024/1024 MB FROM user_segments WHERE segment_name = 'TBL1';
    
            MB
    ----------
        113.75
    

    Lukasz

  • Failed to save data on the DataForm

    Hi all

    I am using Planning 11.1.1.1.0.

    In one of the dataforms I'm trying to get the value of an account for "FY09"-> "BegBalnace'-> 'Real', but when I hit the button 'Save'... the data disappears...

    This specific account has 'STore' as storage device... "Expenses" as a type of account, no brothers and sisters and one of their parents, I also "store."

    Any help.would appreciated.

    Kind regards.

    Alicia

    Hello

    It could be an implicit sharing, value store members account essbase "Never share" and to update it, and then try again.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Help simple loop for no data found

    I am new to PL/SQL and will have problems trying to manage people entering in a good REC BANNER_ID. In the beginning of the game
      for rec in c1 loop
          select SPRIDEN_pidm into pidm 
            from SPRIDEN
           where SPRIDEN_ID = rec.BANNER_ID and SPRIDEN_CHANGE_IND is null; 
    I get no data found when an identification number is entered that does not exist in the spriden table. I want to be able to have the people who did not go in a good REC BANNER_ID in skipped records County which is towards the end. I tried a lot of things, but I do not seem to get anywhere. I'm sure it's pretty simple. I think I need to add some kind of "* IF."
    statement to the article mentioned above. Here is the whole part of the code
    --set serveroutput on format wraped;
    set serveroutput on;
    set verify off;
    spool /u03/banjobs/LOCAL/student/scholar_insert.txt
    Declare
       term_code  varchar2(6) := '&&TERM';
       cursor c1 is select * from ttubantemp.SXTSCHOLAR;
       Pidm  Number;
       so   varchar2(2);
       icnt  number := 0;
       cnt   number := 0;
       insert_cnt number := 0;
       update_cnt number := 0;
       exist_cnt  number := 0;
       skip_cnt   number := 0;
    BEGIN
       dbms_output.enable (buffer_size => null);
       for rec in c1 loop
          select SPRIDEN_pidm into pidm 
            from SPRIDEN
           where SPRIDEN_ID = rec.BANNER_ID and SPRIDEN_CHANGE_IND is null;
           Select Count(*) Into Cnt
             From SPRCMNT
             Where Sprcmnt_Pidm = Pidm
             And Sprcmnt_Cmtt_Code = 'SO';
     --        and SPRCMNT_TEXT not like term_code;
          If Cnt > 0 Then
             Select Sprcmnt_Cmtt_Code Into So
               From Sprcmnt
              Where Sprcmnt_Pidm = Pidm
              and  SPRCMNT_CMTT_CODE = 'SO';
          Else
             so := null;
          end if;
    --
          dbms_output.put_line('BANNER_ID = '||rec.BANNER_ID||
                               ' - PIDM = '||Pidm||
                               ' - Term = '||Term_Code||
                               ' - cnt = '||Cnt);
                          
            If Pidm Is Not Null
            then
             Select Count(*) Into Cnt 
               From Spriden
              Where Spriden_Pidm = Pidm
              And So Is Null;
             if cnt > 0 then
                dbms_output.put_line('   INSERTING');
               INSERT INTO sprcmnt(
                  SPRCMNT_PIDM,
                  SPRCMNT_CMTT_CODE,
                  SPRCMNT_TEXT,
                  SPRCMNT_TEXT_NAR,
                  SPRCMNT_CONFIDENTIAL_IND,
                  SPRCMNT_DATE,
                  SPRCMNT_ORIG_CODE,
                  SPRCMNT_ACTIVITY_DATE,
                  SPRCMNT_CTYP_CODE,
                  SPRCMNT_CONTACT_DATE,
                  SPRCMNT_USER_ID,
                  SPRCMNT_CONTACT_FROM_TIME,
                  SPRCMNT_CONTACT_TO_TIME)
           VALUES (pidm,
                  'SO',
                  term_code,
                  NULL,
                  'N',
                  Sysdate,
                  'SCHL',
                  SYSDATE,
                  NULL,
                  Null,
                  'NEXTGEN',
                  NULL,
                  NULL);
                insert_cnt := insert_cnt + 1;
             else
              select count(*) into cnt 
               from sprcmnt
              Where Sprcmnt_Pidm = Pidm
               And So Is Not Null
               And Sprcmnt_Text Like '&&%TERM%';
                if cnt > 0 then
                   dbms_output.put_line('   UPDATING');
                   update sprcmnt
                      set SPRCMNT_TEXT = SPRCMNT_TEXT||' '||term_code
                    where SPRCMNT_PIDM = pidm
                      and  SPRCMNT_CMTT_CODE = 'SO';
                    update sprcmnt
                      set SPRCMNT_ACTIVITY_DATE = sysdate
                    where SPRCMNT_PIDM = pidm
                      and  SPRCMNT_CMTT_CODE = 'SO';
                     Update Sprcmnt
                      set SPRCMNT_USER_ID = 'NEXTGEN'
                    where SPRCMNT_PIDM = pidm
                      and SPRCMNT_CMTT_CODE = 'SO';
                    update_cnt := update_cnt + 1;
                 else
                    dbms_output.put_line('   RECORD EXISTS');
                    exist_cnt := exist_cnt + 1;
                 end if;
             end if;
             icnt := icnt + 1;
          else
              dbms_output.put_line('SKIPPED BANNER_ID = '||rec.BANNER_ID);
              skip_cnt := skip_cnt + 1;
          end if;
       end loop;
       commit;
       dbms_output.put_line('Total Records    = '||icnt);
       dbms_output.put_line('Records Inserted = '||insert_cnt);
       dbms_output.put_line('Records Updated  = '||update_cnt);
       dbms_output.put_line('Records Existed  = '||exist_cnt);
       dbms_output.put_line('Records Skipped  = '||skip_cnt);
    END;
    /
    spool off;
    /
    EXIT
    Here are the results I get with 1 id good and a bad id

    Error report:
    ORA-01403: no data found
    ORA-06512: at line 15 level
    01403 00000 - "no data found".
    * Cause:
    * Action:
    BANNER_ID = T00001227 - PIDM = 1450 - term = 201280 - cnt = 0
    INSERTION OF

    Engage

    Here are the results with only a good idea

    anonymous block filled
    BANNER_ID = T00001227 - PIDM = 1450 - term = 201280 - cnt = 0
    INSERTION OF
    Total records = 1
    Inserted records = 1
    Put records = 0
    Folders existed = 0
    Ignored records = 0

    Engage

    Edited by: Withnoe 6 July 2012 14:27

    Put another block of start-end inside the loop (around your select statement) and includes an exception handler.
    Pseudocode here:

    for rec in c1 loop
      BEGIN
          select SPRIDEN_pidm into pidm
            from SPRIDEN
           where SPRIDEN_ID = rec.BANNER_ID and SPRIDEN_CHANGE_IND is null;
      EXCEPTION WHEN NO_DATA_FOUND THEN
        dbms_output.put_line('SKIPPED BANNER_ID = '||rec.BANNER_ID);
        skip_cnt := skip_cnt + 1;
      END;
    .
    .
    .
    end loop;
    

    In addition, if you count the records to see if he has at least 1 card that meets the condition, why count ALL records? You can count and put "rownum = 1" or "" rownum < 2"="" so="" it="" stops="" when="" it="" gets="" to="" one="" row.="" another="" way="" i="" like="" to="" do="" it="" is="" "select="" count(*)="" from="" dual="" where=""> ".

    But often there is no need to count at all. People will sometimes do a count to see if there is to be done and if so, then run. In many cases, it is best to try just to get the job done without counting any first.

  • Load and save data of the façade settings

    Can someone give me some examples of VI that ables user so save his choice front face? And tell me if it is possible to save values and strings of all the fields that have been filled by the user. I want to implent a settings 'LOAD' and 'SAVE', and I want these parameters can be read out of LabView, to facilitate the intereaction of the user.

    It would be wonderful if someone can support me in this.

    Thank you very much

    AMT

    Hello

    I have attached a very quick example and dirty.  But you should get the idea of how do

    Craig

  • How to save data from the RT at base of remote Citadel using Citadel api writing

    I try to get a target RT to launch a VI when it is started, which acquires the data and sends them to a database of Citadel on a networked computer.

    I'm doing it with the Citadel write API, more precisely the functions in the DSC module; Open the trace and write trace close path.

    I have a project with the added goal of RT. I have a simple VI under job-generating data and sending it to the local database of the Citadel. This VI works very well and the data is written to the database. However, I have a similar VI under the RT target but open VI track is broken and the VI will not run. It seems that one of the subVIs in Open Trace VI is broken and will not run.

    I'm missing something here. Can someone help me understand this?

    The VI is probably not compatible with real-time, perhaps she calls a DLL or something. What you need to transfer data from RT on a Windows host computer and let that host the insertion in the Citadel.

    Mike...

  • How can you save data of the iCloud on an external hard drive?

    How can I record data of the iCloud on an external hard drive?

    Is not possible. iCloud requires a Wi - Fi connection to synchronize data. Cannot do it on an external drive.

Maybe you are looking for

  • Missing error profile

    Firefox does not load. Error is "profile is missing or incomplete. I tried Firefox in removing and reinstalling. Same mistake. Where is my profile and how to fix it?

  • lock motor when you press

    Hi all I need to drive a lock when the button signal operated with a Boolean value. How can I do? PS I don't have the button in the front panel... but I need to change a Boolean value into a momentum. Thank you

  • Formatting of HTML reports

    Hello I use LabVIEW to generate reports using HTML file. These reports contain plots, images, tables and text blocks. Ideally, I would like all in LabVIEW format so I can't do any post processing of the document. I would like to make some parts bold,

  • Recovery error file path

    I was getting a windows hard disk failure message. I took an external hard drive and selected the option "move to" for a large file folder. (In my ignorance), I thought I'd be able to simply recover this folder, after that I got the replaced disk. I

  • LaserJet professional M1217 nf: cannot scan over network with a printer laserjet 1217 on a Mac

    Hello My set up: Mac with Yosemite LaserJet M1217 more wireless Description of the problem: I can't scan. Preview, the control panel or image capture, I get the same error saying "cannot open a session. I have installed and reinstalled the drivers/pr