string.Intern(…) – Minimising Memory Footprint

I had a one particular view (in the UI) that loaded denormalised data with many repetitive strings. There was nothing much we could do to minimise the volume of the data loaded, however during profiling I realised that most memory was consumer by strings, and most of them were the same.

I remembered a feature of a ‘string’ to intern the value i.e. two or more string having the same value would point to the same memory location without duplication. Applying this technique allowed me to save about 2/3 of the memory consumed. There was one downside though, this memory would never be reclaimed.

So now I’m thinking of writing my own interning using WeakReference

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at

Up ↑

%d bloggers like this: