You are here: Basics Operations & Concepts > Activation Concept

Activation Concept

Activation is a db4o mechanism which controls object instantiation. Why is it necessary? Let's look at an example of a stored tree structure. There's one root object, which has a bunch nodes. Each node has again a few subnodes and so on and so forth. What happens when you run a query and retrieve the root object? All the sub-objects will have to be created in the memory! If the tree is very large, this will fill up your memory.

Luckily db4o does not behave like this. When a query returns objects, they are loaded into memory (activated in db4o terms) only to a certain activation depth. In this case depth means "number of member references away from the original object". All the fields beyond the activation depth are set to null or to default values. So db4o does not load the whole object graph. Instead, db4o loads only the parts of the object graph you are interested in.

Activation occurs in the following cases:

  1. When you iterate over query results.
  2. Object is activated explicitly with the object containers activate method.
  3. Collections members are activated automatically, when the collection is activated, using at least depth 1 for lists and depth 2 for maps.

For a concrete example of the activation process: See "Activation In Action"

If you want to automate the activation process: See "Transparent Activation"