Memory problem

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Hanne Berthelsen
Posts: 15
Joined: Thu 18 Nov 2004 07:51

Memory problem

Post by Hanne Berthelsen » Tue 20 Jun 2006 08:46

I am using MySQL Data Access Component (MyDAC) v. 4.00.1.6 / Borland C++ Builder 5

My application slowly "eats up memory" if regularly accessing a field that does not exist even though there is a try ... catch around accessing the nonexisting field.

try
{
GroupID = MyTable->FieldByName("GroupID")->AsInteger;
}
catch (...)
{
GroupID = 0;
}


Would it help to upgrade to latest version of MyDAC ?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 20 Jun 2006 09:50

We couldn't reproduce described problem using the current MyDAC build. Try downloading current version of MyDAC (4.30.1.15) and test the problem once more. If it persists then send us (evgeniyD*crlab*com) please a complete small sample to demonstrate it, including script to create and fill table.

Hanne Berthelsen
Posts: 15
Joined: Thu 18 Nov 2004 07:51

Post by Hanne Berthelsen » Wed 21 Jun 2006 08:30

I have tried MyDAC v. 4.30.1.15 - problem still exists.

I have sent an example to 'evgeniyD*crlab*com'

Regards Hanne

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 21 Jun 2006 12:59

We have thoroughly tested this problem. This is memory leak of C++Builder error handling system. It appears when handling exceptions that are raised from functions in dcu made by Delphi. It can be easily reproduced using ADO components instead of MyDAC or by calling

Code: Select all

DatabaseError("Some text");
instead of

Code: Select all

GroupID = MyTable->FieldByName("GroupID")->AsInteger;

Hanne Berthelsen
Posts: 15
Joined: Thu 18 Nov 2004 07:51

Post by Hanne Berthelsen » Wed 21 Jun 2006 13:15

Does anybody know :
Would it also happen for if upgrading to C++ Builder 6 or Borland Developer Studio 2006?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 21 Jun 2006 14:49

We can reproduce this problem in C++Builder 6 but not in Borland Developer Studio 2006. We have tested the solution you have sent us by e-mail. Changing

Code: Select all

catch (...) 
to

Code: Select all

catch (Exception &E) 
really helps to avoid the memory leak.

Hanne Berthelsen
Posts: 15
Joined: Thu 18 Nov 2004 07:51

Post by Hanne Berthelsen » Thu 22 Jun 2006 07:00

I have tested during the last 15 hours. No memory has been lost at all.

Exception has been raised more than 125,000,000 times.

So it is the catch (...) for Borland C++ Builder 5/6 that is the problem and should be substituted by catch (Exception &E).

Post Reply