Page 1 of 1

Memory leak MyDac 7.1.4 on large field lists

Posted: Wed 04 Jan 2012 17:52
by nigel_1
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

demo code sent

Posted: Wed 04 Jan 2012 22:35
by nigel_1
Email with demo code sent

Posted: Thu 05 Jan 2012 10:08
by AndreyZ
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.

Not the main problem

Posted: Thu 05 Jan 2012 10:16
by nigel_1
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

Posted: Thu 05 Jan 2012 15:33
by AndreyZ
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.

Update MyDac / SDac

Posted: Thu 05 Jan 2012 16:54
by nigel_1
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

Posted: Mon 09 Jan 2012 09:16
by AndreyZ
If you reproduce the problem with memory leak using either MyDAC or SDAC, please contact us. We are looking forward to hearing from you.