Memory leak MyDac 7.1.4 on large field lists

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
nigel_1
Posts: 8
Joined: Thu 22 Dec 2011 09:45
Location: Italy

Memory leak MyDac 7.1.4 on large field lists

Post by nigel_1 » Wed 04 Jan 2012 17:52

Hi,

Using a large field list and a WHERE clause in to call MySQL V5.5 and then using MyQuery.fieldByName function causes a memory leak.

It does appear to depend on the table structure you are calling.


MyQuery := TMyQuery.Create(Nil);
MyQuery.Connection := SQL_C; (connected TMyConnection)

MyQuery.Close;
MyQuery.SQL.Clear;
MyQuery.SQL.Add(' SELECT * ');
MyQuery.SQL.Add(' FROM ');
MyQuery.SQL.Add(' livedata ');
MyQuery.SQL.Add(' WHERE ');
MyQuery.SQL.Add(' VehicleServerID = 1);

MyQuery.Open;

UnitMake := MyQuery.FieldByName('VehicleUnitMake').AsString;

MyQuery.Destroy;


It only appears to affect string values and takes around 8192 bytes on every call.

If you need the table I am using I am happy to send this as an export.

Thanks In Advance
Nigel

nigel_1
Posts: 8
Joined: Thu 22 Dec 2011 09:45
Location: Italy

demo code sent

Post by nigel_1 » Wed 04 Jan 2012 22:35

Email with demo code sent

AndreyZ

Post by AndreyZ » Thu 05 Jan 2012 10:08

Hello,

The memory leak you found occurs because you don't free the TMyConnection component that you create dynamically in the code. To solve this problem, you should free TMyConnection. I've sent you your sample with needed corrections.

nigel_1
Posts: 8
Joined: Thu 22 Dec 2011 09:45
Location: Italy

Not the main problem

Post by nigel_1 » Thu 05 Jan 2012 10:16

Hi and thanks,

But the memory is "leaked" on every sql call not just on the connection being left at the end.

Please run the code on table I sent to you and you will see the problem

This is a big problem to me at this time as I have 24/7 systems leaking memory and I have to re-start the applications every day.

Regards
Nigel

AndreyZ

Post by AndreyZ » Thu 05 Jan 2012 15:33

I removed all unnecessary code that allocates memory in your sample (that does not concern MyDAC components), and executed the code where data is read one thousand times. The memory was allocated and freed correctly and there were no memory leaks. I've sent you your sample with my corrections. Please change it to demonstrate the problem with memory.

nigel_1
Posts: 8
Joined: Thu 22 Dec 2011 09:45
Location: Italy

Update MyDac / SDac

Post by nigel_1 » Thu 05 Jan 2012 16:54

Hi,

Thanks for the example code back, I still got the memory leak but I think it is due to my having both MyDac and Sdac installed, once I removed the SDac the memory leak stopped.

I have run and run the code now and its ok.

I will re-install the SDac and watch the memory usage following that, its a very odd situation.

Many thanks for your input and time during a very frustrating problem.

Regards
Nigel

AndreyZ

Post by AndreyZ » Mon 09 Jan 2012 09:16

If you reproduce the problem with memory leak using either MyDAC or SDAC, please contact us. We are looking forward to hearing from you.

Post Reply