You are here: Configuration > Common Configuration > Intern Strings

Intern Strings

You can configure db4o to call the intern method on all strings. See more on the intern method for your platform.

EmbeddedConfiguration configuration = Db4oEmbedded.newConfiguration();
configuration.common().internStrings(true);
CommonConfigurationExamples.java: intern strings

Benefits

When a lot of strings contain a the exact same content, calling intern on them can safe some memory.

Disadvantage

Calling intern on a string adds that string to a global pool. Therefore this string cannot be garbage collected. So when you load a lot of strings which you use only once, you can run into memory-problems.