Works on this device
Container Memory Estimator
Work out how much memory one container needs. Add up its parts (runtime, heap, threads, connections, other memory) with a safety margin, find the largest heap that fits a limit, or start from the use you measured. You get a memory request and limit in Kubernetes form, such as 768Mi.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use this estimator
- Choose Memory request and limit from the parts, Largest heap that fits a memory limit, or Request and limit from measured use.
- Type each part with its unit. Use figures you measured for your program where you can.
- Type a safety margin, such as 20%.
- Choose Calculate. Copy the lines for the manifest, or download the result as a CSV file.
The formulas
- Estimated use = base + heap + threads × memory per thread + connections × memory per connection + page cache headroom + other memory.
- Memory request = estimated use, rounded up to the step (64 MiB unless you choose another).
- Memory limit = estimated use × (1 + margin ÷ 100), rounded up to the step.
- Largest heap = limit ÷ (1 + margin ÷ 100) − all other parts.
- From measured use: request = usual use and limit = highest use × (1 + margin ÷ 100), each rounded up.
- The page adds exact fractions of bytes, so the totals do not drift.
Worked example
A service with a base of 120 MiB, a heap of 512 MiB, 50 threads of 1 MiB, 100 connections of 64 KiB (6.25 MiB) and 64 MiB of other memory uses 120 + 512 + 50 + 6.25 + 64 = 752.25 MiB. Rounded up to 64 MiB, the request is 768Mi. With a 20% margin it is 902.7 MiB, so the limit is 960Mi.
With a limit of 1 GiB and the same other parts (240.25 MiB) and margin, the heap may be up to 1024 ÷ 1.2 − 240.25 ≈ 613.08 MiB, so -Xmx613m.
Measured: usual use 450 MiB and highest use 700 MiB. Request 512Mi; limit 700 × 1.2 = 840 MiB, rounded up to 896Mi.
Limits you should know
- The parts are your own figures; this page has no table of what runtimes need. An estimate from parts can miss native memory, memory-mapped files and growth over time: check it under real load.
- A container above its memory limit is stopped (OOMKilled). A request below the real use lets the node run short of memory under load.
- Page cache that the kernel can free is counted to the container; leave room for it if the program reads or writes many files.
- The margin is a choice, not a rule. For CPU and for the whole pod, use the Container Resource Calculator.