Global Activation Settings

Java: Db4o.configure().activationDepth(activationDepth)

configures global activation depth, which will be used for all objects instead of the default value. This method should be called before opening a database file.

Java:ExtObjectContainer.configure().activationDepth(activationDepth)

has a similar effect, but the setting will be applied to the specific ObjectContainer and can be changed for the open database file.

ActivationExample.java: testActivationConfig
01public static void testActivationConfig(){ 02 storeSensorPanel(); 03 ObjectContainer db = Db4o.openFile(Util.YAPFILENAME); 04 try { 05 db.ext().configure().activationDepth(1); 06 System.out.println("Object container activation depth = 1"); 07 ObjectSet result = db.get(new SensorPanel(1)); 08 listResult(result); 09 if (result.size() >0) { 10 SensorPanel sensor = (SensorPanel)result.get(0); 11 SensorPanel next = sensor.next; 12 while (next != null){ 13 System.out.println(next); 14 next = next.next; 15 } 16 } 17 } finally { 18 db.close(); 19 } 20 }

By configuring db4o you can have full control over activation behavior. The two extremes:

  • using an activationDepth of Integer.MAX_VALUE lets you forget about manual activation, but does not give you the best performance and memory footprint;
  • using an activationDepth of 0 and activating and deactivating all objects manually keeps memory consumption extremely low, but needs more coding and attention.