Berkeley DB under .NET - Resource management -
11-14-2005
, 03:08 PM
I am currently creating a C# 2.0 wrapper for the basic BDB structures
(Environment, Cursors, Transactions, Sequences).
This seems to work fine so far, but the main difficulty
I am currently facing is how to protect resources and
prevent access violations in case of programmer error.
This is mostly difficult because I don't quite understand
how resources are freed internally in BDB.
Apparently, closing one object may also implicitly close another.
For instance: when a parent transaction is closed (aborted/committed),
it automatically closes child transactions, so one must no call
Abort/Commit on the child transaction, if one does not want to get
memory access violations/segfaults.
So, I need to track a few dependencies.
My initial questions are:
a) If I close the environment, what else need closing?
databases? sequences? transactions?
b) If I close the database, does that really de-allocate all cursors?
Does it also close/de-allocate the sequences?
this questions are not about proper programming, but about
protecting against improper programming. Basically, I need
to write the finalization code such that it cleans up everything
in the right order, without calling Close() when not needed,
as this would cause access violations.
Grateful for any feedback,
Karl |