LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

memory problem sql toolkit

Solved!
Go to solution

Hi

we are using CVI 2012 and SQL Toolkit 2.2. Once a minute we are searching a SQL database for a special record and we update the data in this record. After updating we close the database. Each time we do this procedure we see in the taskmanager that the memory our program needs increases.

After a couple of minutes (20-30) we get a memory error message.

 

Does anybody know if this is a know problem or does anyone can help us?

 

Thanks in advance

Oliver

 

here is some of the code:

 

    //
    hdbc = DBConnect(DATABASE_STRING);

    //
    hsql = DBActivateSQL(hdbc, "SELECT * FROM `data_l01`");

    //
    rw = DBBindColChar(hsql, SQL_DATE, 32,        cDB_Date,            &iDB_Date_State, "");
    rw = DBBindColChar(hsql, SQL_TIME, 32,        cDB_Time,            &iDB_Time_State, "");
    rw = DBBindColInt(hsql, SQL_SPEED,            &iDB_Clock,            &iDB_Clock_State);

    // Flag, ob der Eintrag gefunden wurde loeschen
    iFoundFlag = 0;

    // Find the record we want to update
    while((rw = DBFetchNext(hsql)) == DB_SUCCESS)
        {
        //
        if( (StrICmpWithoutSurrWhiteSpace(cDB_Date, cDate) == 0) &&
            (StrICmpWithoutSurrWhiteSpace(cDB_Time, cTime) == 0))
            {
            // Flag, ob der Eintrag gefunden wurde setzen
            iFoundFlag = 1;
            break;
            }
        } // Ende von Find the record we want to update

        // Daten uebernehmen
        iDB_Clock            = iClock;

 

        // Insert the record into the database
        rw = DBPutRecord(hsql);

        //
        rw = DBDeactivateSQL(hsql);

        //
        rw = DBDisconnect(hdbc);


0 Kudos
Message 1 of 4
(3,148 Views)

Hi

 

I found out that the SQL Toolkit 2.2 has a "Resource leak detection" feature. Did you try this tool to detect the source of the memory leak?

 

LabWindows™/CVI SQL Toolkit 2.2 Readme

http://digital.ni.com/public.nsf/allkb/1AD91B4894FBE4E8862576F500803E93?OpenDocument

 

Best regards

Raphael

0 Kudos
Message 2 of 4
(3,110 Views)
Solution
Accepted by topic author OZI

Hi Oliver,

 

From reading your code, I understand that you're opening a database connection for every update that you want to perform.

Generally I would advice you to open the database connection on startup once and hold this reference until the program is closed, instead of reopening it everytime.

 

This could potentially solve your problem.

 

Please let me know if that solved your problem.

 

Best regards

Raphael

Message 3 of 4
(3,092 Views)

Hello Raphael,

yes I came to the same point.

 

Last week I was at our customer and I modified the code that the database will be opened only once during the startup and closed with the programm end. The access to the database is done in a thread.That means that the database is open the whole time.

 

After this modification there was no more problem with the leak of memory. I watched the taskmanager a long time but there was no more rising memory

 

Thanks a lot for your help.

 

greetings

Oliver

0 Kudos
Message 4 of 4
(3,086 Views)