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.

IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
configuration.Common.InternStrings = true;
CommonConfigurationExamples.cs: intern strings
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration()
configuration.Common.InternStrings = True
CommonConfigurationExamples.vb: 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.