You are here: Object Lifecycle > Activation


Activation is a db4o mechanism, which controls object's fields instantiation. Why is it necessary? Let's look at an example of a database, that has a Tree structure, i.e. there is one Root object, which has N nodes, each node in its turn has K subnodes etc. Let the whole structure has M levels. What happens when you run a query, retrieving the root object? All the sub-objects will have to be created in the memory. If N,K,M are large numbers, you will most probably end up with the OutOfMemory exception.

Luckily db4o does not behave like this - when query retrieves objects, their fields are loaded into memory (activated in db4o terms) only to a certain depth - activation depth. In this case depth means "number of member references away from the original object". All the fields at lower levels (below activation depth) are set to null (for classes) or to default values (for primitive types).

Activation occurs in the following cases:

  1. ObjectSet#next() is called on an ObjectSet retrieved in a query;
  2. Object is activated explicitly with ObjectContainer#activate(object, depth);
  3. built-in collection element is accessed;
  4. for the environment collections (.NET, Java) their members are activated automatically, when the collection is activated, using at least depth 1 for lists and depth 2 for maps.

More Reading: