Page 1 of 1

TMyEmbConnection and file handles

Posted: Wed 28 Jan 2015 02:09
by skydvrz
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?

Re: TMyEmbConnection and file handles

Posted: Wed 28 Jan 2015 11:09
by ViktorV
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.

Re: TMyEmbConnection and file handles

Posted: Wed 28 Jan 2015 15:24
by skydvrz
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.

Re: TMyEmbConnection and file handles

Posted: Thu 29 Jan 2015 10:15
by ViktorV
In this case, to free file handlers after freeing all threads, you can call the MyAPIEmbedded.FreeMySQLLib method in the main thread.