02-28-2013 08:43 AM
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);
Solved! Go to Solution.
03-07-2013 07:03 AM
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
03-11-2013 03:24 AM
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
03-11-2013 03:46 AM
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