I’ve released a new version of OCaml-MariaDB. The main change is that now library users are expected to call Mariadb.library_end explicitly when they are done using the library. Previously this function was called automatically after Mariadb.close. While this is fine when linking to libmysqlclient, it breaks the Connector/C (libmariadbclient) when multiple database connections are instantiated. This problem was reported by Donovan Mueller.
This release also includes contributions by Petter Urkedal and Jan Pöschko.
Some memory would never be freed by the C library. I guess in most situations this shouldn’t really be a problem, as it would be called just before the program exits anyway.
For close this should be simple but for library_end I’m not so sure, because the point where it can be called depends on the application. You could put the call in some sort of at_exit function if you don’t want to worry about forgetting it, but it really depends on your code.
OCaml-MariaDB is intended to be mostly a low level wrapper around the C client libraries, which is why it doesn’t have a lot of utility functions. The idea is to provide something that higher level libraries such as Caqti can use as a driver.
Can library_end be called more than once? If so, you could set up an at_exit by default. That would make usability much better. Alternatively you could place it in a GC finalizer.