Memory lost on query

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Albert van Pelt
Posts: 11
Joined: Wed 06 Jan 2010 16:48
Location: Eindhoven

Memory lost on query

Post by Albert van Pelt » Wed 06 Jan 2010 17:03

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 ?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 08 Jan 2010 08:14

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.

Albert van Pelt
Posts: 11
Joined: Wed 06 Jan 2010 16:48
Location: Eindhoven

Memory lost on query

Post by Albert van Pelt » Fri 08 Jan 2010 15:56

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...

Albert van Pelt
Posts: 11
Joined: Wed 06 Jan 2010 16:48
Location: Eindhoven

Post by Albert van Pelt » Fri 08 Jan 2010 15:59

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.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 11 Jan 2010 08:22

Please specify the MyDAC version you are using.

Albert van Pelt
Posts: 11
Joined: Wed 06 Jan 2010 16:48
Location: Eindhoven

Post by Albert van Pelt » Mon 11 Jan 2010 08:35

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");

Albert van Pelt
Posts: 11
Joined: Wed 06 Jan 2010 16:48
Location: Eindhoven

Post by Albert van Pelt » Mon 11 Jan 2010 08:38

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.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 11 Jan 2010 10:25

I still can not reproduce the problem. In order to investigate the problem cause we need a sample to demonstrate the problem.

Albert van Pelt
Posts: 11
Joined: Wed 06 Jan 2010 16:48
Location: Eindhoven

Still looking because it is not persistent...

Post by Albert van Pelt » Sun 14 Feb 2010 22:36

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%'

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 15 Feb 2010 09:06

Please check that you free the memory, you have allocated, on reading data from TMyQuery.
We still can not reproduce the problem.

Albert van Pelt
Posts: 11
Joined: Wed 06 Jan 2010 16:48
Location: Eindhoven

Free ?

Post by Albert van Pelt » Mon 15 Feb 2010 15:23

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. :oops:

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 16 Feb 2010 08:56

Try to compose a COMPLETE sample to demonstrate the problem and send it to dmitryg*devart*com.

Albert van Pelt
Posts: 11
Joined: Wed 06 Jan 2010 16:48
Location: Eindhoven

Garbage collector

Post by Albert van Pelt » Thu 18 Feb 2010 10:50

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

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 18 Feb 2010 14:01

Delphi doesn't use the garbage collector.
Maybe, when you use the dll, you don't free the memory, you have allocated.

Albert van Pelt
Posts: 11
Joined: Wed 06 Jan 2010 16:48
Location: Eindhoven

Using C++ Builder

Post by Albert van Pelt » Thu 18 Feb 2010 14:39

Sory but am using C++Builder 2009 from codegear

Post Reply