Page 1 of 2
Memory lost on query
Posted: Wed 06 Jan 2010 17:03
by Albert van Pelt
I loose 1.2 MB on a get query. This is not consistant.
One out of 1000 queries will result in a memory usage increase of 1.2 Mb.
I use the VCL component in my dll.
The functions i use are threaded.
I use a connection manager with 100 connections. = 100 times TMyConnection -- TMyQuery
I only activate a connection when i use it.
The same TMyConnection -- TMyQuery can be used for inserting / updating and to get data. Not at the same time.
pSQLConnection->Query->SQL->Text = QueryToGet;
pSQLConnection->Query->Execute(); Query->Eof)
{
pAccount_StatusEntryAddNew = new(SAccount_StatusEntry);
..
}
pSQLConnection->Query->Close();
pSQLConnection->Query->SQL->Clear();
Is there someone that experienced the same.
Ans is there a solution ?
I probably do something wrong....
Is there a setting at MyQuery i forgot, or at MyConnectoin i forgot ?
Posted: Fri 08 Jan 2010 08:14
by Dimon
I could not reproduce the problem.
Please send me a complete small sample to dmitryg*devart*com to demonstrate it, including a script to create and fill table.
Memory lost on query
Posted: Fri 08 Jan 2010 15:56
by Albert van Pelt
I can't make a short sample program a the moment.
I tried several programs using the same way, but the meory leak does not appear.
I know when it happens, and also the connection on which it happens.
PRIO : (3) ID : (2) 52844 / 34436 2010-01-08 16:43:29 - Connectionmanager Get Connection 1
PRIO : (3) ID : (2) 52844 / 34436 2010-01-08 16:43:29 - QueryToInsert connection (1) 1 found inactive connection.
PRIO : (2) ID : (2) 52844 / 34436 2010-01-08 16:43:29 - QueryToInsert connection finished (1) - 0:insert into `SCS`.`scs_locking` ( `SCS_Account_Nmbr`, `SCS_Locking_Mode`, `SCS_Locking_Operator`, `SCS_Locking_DateTime` ) values ( "01007037", '1', "FEP1", '20100108164329' )
PRIO : (3) ID : (2) 52844 / 34436 2010-01-08 16:43:29 - QueryToInsert type (1) 1 changed connection state to inactive connection.
PRIO : (3) ID : (2) 52848 / 34452 2010-01-08 16:43:29 - QueryToGet type 1 search for inactive connection...
PRIO : (3) ID : (2) 52848 / 34452 2010-01-08 16:43:29 - Connectionmanager Get Connection 1
PRIO : (3) ID : (2) 52848 / 34452 2010-01-08 16:43:29 - QueryToGet connection (1) 1 found inactive connection.
PRIO : (1) ID : (2) 52900 / 35752 2010-01-08 16:43:29 - QueryToGet Memory Problem 1
PRIO : (2) ID : (2) 52900 / 35752 2010-01-08 16:43:29 - QueryToGet connection finished (1) - 16:SELECT SCS_Account_Nmbr, SCS_Dealer_Nmbr, SCS_Account_Name, SCS_Account_Backup_Nmbr, SCS_Account_Backup_Alt_Nmbr, .... ` WHERE (SCS_Account_Nmbr = "01007037" OR SCS_Account_Backup_Nmbr = "01007037" ) LIMIT 2
PRIO : (3) ID : (2) 52900 / 35752 2010-01-08 16:43:29 - QueryToGet connection (1) 1 changed connection state to inactive connection.
PRIO : (3) ID : (2) 52900 / 35752 2010-01-08 16:43:29 - QueryToGet connection (1) Memory lost correction
PRIO : (3) ID : (2) 52900 / 35752 2010-01-08 16:43:29 - QueryToGet connection (1) Memory lost correction finished
PRIO : (3) ID : (2) 52872 / 35716 2010-01-08 16:43:29 - QueryToGet type 1 search for inactive connection...
I delete the query component and connection and initialize a new one, but without result.
Is there a debug option i can activate on de TMyQuery ?
In this way i perhaps can see what is happening...
Posted: Fri 08 Jan 2010 15:59
by Albert van Pelt
Sorry some extra info....
PRIO : (1) ID : (2) 52900 / 35752 2010-01-08 16:43:29 - QueryToGet Memory Problem 1
35752 is the virtual memory that has increased with 1.2 Mb.
This is not allways 1.2 sometimes also 7Mb.
If the memory jump happens, it is allways after an execute on a query.
Posted: Mon 11 Jan 2010 08:22
by Dimon
Please specify the MyDAC version you are using.
Posted: Mon 11 Jan 2010 08:35
by Albert van Pelt
I am using :
Codegear2009 C++ Builder with all the service packs loaded.
MySQL Data access components professional edition
Version 5.90.0.54 for RAD Studio 2009
SQL Srver Data access components rofessional edition
version 4.80.0.54 for RAD Studio 2009
I have no problem with any insert, update, delete....
The problem is only for select statements.
I changed the dll, so the functions are allways sequentional, using mutexes, but without result. I added a debug line before the execute and after the execute to determine if it is actualy this line which causes the increase.
DebugManager->InsertDebugMessage(iLocalServerID, 2,"QueryToGet Open " + IntToStr(pSQLConnection->Entry) + " : " + pSQLConnection->Query->SQL->operator [](0));
pSQLConnection->Query->Execute();
DebugManager->InsertDebugMessage(iLocalServerID, 2,"QueryToGet Execute finished");
Posted: Mon 11 Jan 2010 08:38
by Albert van Pelt
Previously i used the versions :
MySQL : 5.70.0.45
SQL : 4.70.0.45
My first action after noticing the increase and checking my code was to get the latest version on the components.
Posted: Mon 11 Jan 2010 10:25
by Dimon
I still can not reproduce the problem. In order to investigate the problem cause we need a sample to demonstrate the problem.
Still looking because it is not persistent...
Posted: Sun 14 Feb 2010 22:36
by Albert van Pelt
Dimon,
Sorry i am trying to get a sample program, but can't dupe in a sample program.
Question
I use the TMyquery to get the info :
pSQLConnection->Query->Close();
pSQLConnection->Query->SQL->Text = QueryToGet;
pSQLConnection->Query->Open();
ProcessQuery();
pSQLConnection->Query->SQL->Clear();
pSQLConnection->Query->Close();
At Processquery i retrieve the data from MyQuery:
while (!pSQLConnection->Query->Eof)
{
.. pointer list with the result.
pSQLConnection->Query->Next();
}
The 1.2 Mb increase is at the Open....
Sometimes....
Seems now to be every +/-15 min.
After many queries likewise.
One thing is 100% sure.
If i don't use a get i don't have any memory increase.....
So insert, delete, update is perfect working in my program.
Only when using a get i sometimes get the problem.
I have the program run the same query over and over again.
Once every 15 minutes the same query results in a 1.2 Mb memory increase.
The query is : SHOW STATUS LIKE 'Ndb%'
Posted: Mon 15 Feb 2010 09:06
by Dimon
Please check that you free the memory, you have allocated, on reading data from TMyQuery.
We still can not reproduce the problem.
Free ?
Posted: Mon 15 Feb 2010 15:23
by Albert van Pelt
Dimon,
Do you mean Clear ?
pSQLConnection->Query->SQL->Clear();
Don't think so, because this is only deleting the SQL statements from the list (i suspect).
I think this is the problem indead, but please advise how to free the memory... which command should i use.

Posted: Tue 16 Feb 2010 08:56
by Dimon
Try to compose a COMPLETE sample to demonstrate the problem and send it to dmitryg*devart*com.
Garbage collector
Posted: Thu 18 Feb 2010 10:50
by Albert van Pelt
Dimon,
Could it be the garbage collector ?
I am still trying to make a sample, but it's complicated, and can't reproduce it in parts.
When i minimize the program it will free the memory, except used at the dll. So could this be likely....
I am using windows 7 with codegear 2009 to develop..
Albert
Posted: Thu 18 Feb 2010 14:01
by Dimon
Delphi doesn't use the garbage collector.
Maybe, when you use the dll, you don't free the memory, you have allocated.
Using C++ Builder
Posted: Thu 18 Feb 2010 14:39
by Albert van Pelt
Sory but am using C++Builder 2009 from codegear