Skip to content
ENExplore Calculators

String Memory Calculator

Estimate the memory strings occupy including object overhead and encoding.

About String Memory Calculator

Short strings are dominated by object overhead rather than content, so a forty-byte header on a ten-character string more than doubles its cost. Interning collapses duplicates to a single copy plus a reference. String duplication is extremely common in parsed data, which is why interning often reclaims a third or more of heap memory.

Formula

String Memory

Bytes per string = object overhead + length × bytes per character

interning
Storing one copy of each distinct value and referencing it
bytes per character
Two for UTF-16 runtimes, one for compact Latin storage

Worked example

With the default values below, String Memory Calculator returns Total Memory of 99.1821. Change any input above and every figure here is recalculated in your browser.

Inputs used

Number of stringsminimum 0
1,000,000
Average length in charactersminimum 0
32
Bytes per characteraccepts 1–4 bytes
2 bytes
Per-string object overheadminimum 0 bytes
40 bytes
Share that are duplicatesaccepts 0–100 %
40 %

Results

Total Memory
99.1821 MB
Memory After Interning Duplicates
67.1387 MB
Bytes per String
104 bytes
Memory Consumed by Object Overhead
38.1470 MB
Saving From Interning
32.31%

Step by step

  1. 1Values used
  2. 2String Memory
  3. 3Total Memory= 99.1821 MB
  4. 4Memory After Interning Duplicates= 67.1387 MB
  5. 5Bytes per String= 104 bytes
  6. 6Memory Consumed by Object Overhead= 38.1470 MB
  7. 7Saving From Interning= 32.31

Assumptions and limits

  • The result is derived only from the 5 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 4 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

How is String Memory calculated?

Bytes per string = object overhead + length × bytes per character Short strings are dominated by object overhead rather than content, so a forty-byte header on a ten-character string more than doubles its cost. Interning collapses duplicates to a single copy plus a reference.

Why does String Memory matter?

String duplication is extremely common in parsed data, which is why interning often reclaims a third or more of heap memory.

What values do I need to enter?

This calculator takes 5 inputs: Number of strings, Average length in characters, Bytes per character, Per-string object overhead, Share that are duplicates. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.

String Memory Calculator – Calculate Total Memory | Calcrivo