TMyEmbConnection and file handles

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
skydvrz
Posts: 32
Joined: Tue 23 Feb 2010 23:49
Location: Kissimmee, Florida USA
Contact:

TMyEmbConnection and file handles

Post by skydvrz » Wed 28 Jan 2015 02:09

When using TMyEmbConnection I see that upon first opening of the database, it uses 32000 file handles. Even if I Free the TMyEmbConnection instance, the file handles remain.

My application runs OK, but between the 32000 initial file handles and apparent slow leakage during database access, I am concerned that it will eventually run out of handles and die.

I am using v8.4.13 in DXE.

Any ideas?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: TMyEmbConnection and file handles

Post by ViktorV » Wed 28 Jan 2015 11:09

MyDAC does not unload Embedded server every time after closing a connection because this is a very slow operation. If you really need to release database files during your application is working, you should add the MySqlApi unit to the uses clause and execute this code:

Code: Select all

  MyAPIEmbedded.FreeMySQLLib;
In addition, the UnloadEmbLibraryOnDisconnect global variable is declared in the MySqlApi module. Its default value is False. You can set UnloadEmbLibraryOnDisconnect to True for unloading MySQL Embedded server library on closing connection.

skydvrz
Posts: 32
Joined: Tue 23 Feb 2010 23:49
Location: Kissimmee, Florida USA
Contact:

Re: TMyEmbConnection and file handles

Post by skydvrz » Wed 28 Jan 2015 15:24

Thank you! I will give it a try.

In my case, datamodules are created in threads. When the thread terminates and the datamodule is freed, I need to close the file DB file handles.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: TMyEmbConnection and file handles

Post by ViktorV » Thu 29 Jan 2015 10:15

In this case, to free file handlers after freeing all threads, you can call the MyAPIEmbedded.FreeMySQLLib method in the main thread.

Post Reply