From: Michael N. <uu...@rz...> - 2002-12-25 19:06:08
|
Elias Karakoulakis wrote: > Hello all and merry christmas! > > I am in the process of extending the IBM DB2 driver and I have to put > forward some points that I came across while working with DBI: > > 1) Memory management in DBI should be rethought of. The DBI layer should > be lenient as to its usage by client apps, which means that calls like > Statement.finish or Database.disconnect should always do their thing > (free C buffers, close log files, turn off the coffee machine etc.) > regardless of their being called by the user script or not. For > instance, the following hypothetical script leaks like hell: > > while [some boolean] > st = db.prepare([some sql]) > st.execute([some values]) > end > > Yes, I know this is not the 'proper' way to use DBI (suppose I never > heard of 'Database.do'). But DBI should at least it should try to invoke > "st.finish unless st.finished?" in a finalizer closure if a statement > object is finalized without having freed its internal resources. The > same applies to database connections and other environment handles. I > don't know if the use of finalizers is the correct way to address the > problem, so I expect your thoughts on this. This is easy to accomplish in an C extension (where the GC calls a free function). In Ruby, you have to use finalizers, which are slow and ugly. Currently most database drivers are just wrappers around some existing database interfaces. This approach is slow and requires more memory, and things like you mentioned above are harder to implement. I am currently planning "Ruby/DBI Next Generation", which should solve many problems (especially performance but also memory related). But due to very spare free time, there will be no release in the next months. Merry Christmas! Regards, Michael |