The thing is, Zeos is automatically caching driver libraries, leaving the handles open even after a connection to a database is closed. You can reproduce the "issue" quite easily: drop a TZConnection on a form, set it to a database of your choice, finally call ZConnection1.Connect and ZConnection1.Disconnect right after it. Once the application is running, try to delete the driver .dll - it won't work as your program is still using it.
Caching is done in the TZAbstractDriver level and the cache can manually be cleared (therefore handles released) like this:
Code: Select all
Type
THackAbstractDriver = Class(TZAbstractDriver);
Var
drivers: IZCollection;
driver: TZAbstractDriver;
a: Integer;
Begin
drivers := DriverManager.GetDrivers;
For a := 0 To drivers.Count - 1 Do
Begin
driver := drivers[a] As TZAbstractDriver;
THackAbstractDriver(driver).FCachedPlainDrivers.Clear;
End;
End;
What do you guys think about this solution? If agreed I can create a pull request even tonight with the changes.