Search code examples
wpfmvvmprismdb4o

Using DB4O in MVVM application with Prism


I would like to use db4o for persisting my business object in Prism aplication. How should I maintain IObjectContainer lifetime? As I know from documentation, when I load object with one container I should save it with the same one. So maybe some kind of singleton scope should be right. But doesn't container keep reference to every object which goes through it and because of this doesn't it cause something like memory leak?

I read something about Conversation per Business Transaction, but it was for nHibernate and I guess nHibernate's session and db4o's container are totally different things.

Just for sure, I am talking about desktop application with embedded db4o. So, no server/client.


Solution

  • For desktop applications it's usually easier to have a global container. That way you just can store / update objects without any issues. So singleton scope should be the right one.

    The db4o container only holds weak references to objects. That means it should never prevent objects from being collected.

    I my desktop App with db4o we have a single object container. After each logical operation we just commit to persist all changes.