๐ง Memory in Podman
How to Size Limits From Measured Use, Deploy Them Safely, and Not Trust an AI's Snapshot
Updated 6 Nov 2026. The original, published 3 Jan 2026, was a generic guide. Parts of it did not survive contact with my own fleet, so I have rewritten it around what actually happened on my Podman LXC.
My Podman LXC is 12 GB of RAM and 8 GB of swap, running about 46 containers. Until late October, every one of them had no memory limit. Nothing had broken, which is a terrible reason to leave it that way.
This is how I fixed it, what the original post got wrong, and the method that worked.
๐ Prerequisites
- Beszel (hub and agent) running and collecting per-container history. Apart from Podman's own settings and checks, all the raw data in this post came from Beszel. You need weeks of history, not a snapshot
- Read access to Beszel's data. I worked from a read-only copy of its database
- cgroups v2 with delegation to the container (a Proxmox LXC provides this)
- A stack file per service (Compose-style) so each limit is versioned and easy to roll back
- Podman itself, for verifying that limits were actually applied (
podman inspect,podman ps) - AI Oversight, giving an AI access has proven a god send. It can process information, logs far faster than a human can, and it has expediated a great many issues. Just do it in a way that follows best practices. If the AI has access to the assorted API's
๐ Why Limit Memory in a Small LXC
This is host protection, not performance tuning. One runaway container should hit its own ceiling and die alone, rather than push everything else into swap.
The limits here are backstops. They are deliberately generous.
๐งช Measure First (and Why podman stats Misleads)
The original post said to watch podman stats and free -h. On their own, they mislead:
- Page cache counts toward a cgroup limit, but it is reclaimable. A file-heavy container looks huge and isn't.
- Kernel peak counters only cover the time since the container was created.
Jellyfin showed a 3.1 GB "peak" that was mostly cache. Its real working set peaked at 164 MB.
The baseline on 14 Oct, before any limits:
| Measure | Value |
|---|---|
| Real application memory | ~2.8 GB |
| File cache | 6.2 GB |
| Swap in use | 4.6 GB (cold) |
| Memory pressure (PSI) | zero |
| OOM kills | none |
What worked was working-set history with page cache excluded. Beszel keeps this per container. I read a copy of its database read-only and took the maximum per container over about 30 days (7 Oct to 6 Nov).
One honest caveat: Beszel stores averaged samples (20-minute averages for 24 hours, 2-hour for 7 days, 8-hour for 30 days). Short spikes are smoothed away, so these are not true maximums. That is the main reason for the headroom below.
๐งฉ The Sizing Rule
Limit = measured maximum ร 2 to 4. Go higher for anything that spikes: JVM, .NET, transcoding, browser-based tools.
Page cache is reclaimable under a cgroup limit, so big headroom should not cause kills. My old guesses (128-512 MB lightweight, 256-1024 MB Node/Python, 4-6 GB GPU) turned out roughly right, but they were guesses. These came from data:
| Service | Limit | Measured max (MB) | Note |
|---|---|---|---|
| Media server (public) | 2g | 151 | Unlimited until 6 Nov |
| Request manager (public) | 512m | 211 | |
| Blog / its MySQL | 512m / 1g | 178 / 384 | |
| JVM app / its MariaDB | 2g / 512m | 750 / 177 | JVM, left room |
| Media automation (.NET) | 256m-512m each | 70-163 | |
| Downloader / browser-based helper | 1g / 1536m | 17 / 101 | Helper hit 657 MB on a real request |
| Monitoring and management tools | 128m-1g | 21-508 | The one I need for recovery got generous headroom. One tool's p95 was 168 against a 508 max |
| LLM runtime / its web UI | 6g / 1g | 2381 / 621 | Max since 30 Oct only |
| Automation tool / its Postgres | 2g / 512m | 460 / 8 | |
| Packet analyser | 2g | 249 | Its 1 GB shared memory counts |
| Small utilities, search, dashboards | 128m-512m | 3-96 |
Databases: the original post said to avoid strict limits on them. I limited them anyway, from measured use. Postgres and MariaDB got 512m, the blog's MySQL got 1g, against working sets of 8, 177 and 384 MB. A limit set blind is risky. A limit at several times the measured working set is a different thing.
๐งฉ Which Key (and What Swap Does)
The original said to use deploy.resources.limits.memory. I have not tested that, and I can't vouch for it under my deployment manager or docker-compose over the Podman socket.
What I use is the service-level mem_limit key:
healthcheck: ...
mem_limit: 512m
I verified that it gives memory.max equal to the limit and swap.max equal to twice the limit.
The original also said to set --memory-swap equal to --memory to stop swap thrashing. I haven't done that here. With mem_limit alone the swap allowance is double, and the stacks run that way. If you want the stricter setting, test it first.
In my stack files mem_limit always sits directly after healthcheck, so it is always in the same place.
๐ Deploying Safely
One stack at a time, through my deployment manager:
- Stop the stack completely.
- Deploy with force-recreate.
- Check before moving on:
- All containers healthy
podman inspectshowsHostConfig.Memoryas intended- The conmon process is alive
nft list ruleset | grep dnatshows no duplicate or stale rules- The public hostname answers
- No OOM kills
Every stack file gets a version bump, a changelog line, a note on how it was sized, and a rollback: delete the line and redeploy.
I dropped pids_limit on purpose. Podman already caps every container at 2048 processes, and each extra recreate is another chance at the problems below.
๐งฉ Detecting When a Limit Is Too Tight
Same signs as before, plus a harder check:
- Container restarting unexpectedly
- Logs showing memory allocation failures
podman psshowing recent restarts- A non-zero
oom_killin the container'smemory.events
If it happens, raise that one limit and retest.
After the 6 Nov deploys I found no OOM kills in the kernel log and no container with a non-zero oom_kill. But the new limits have only run briefly under normal load. I have not tested a heavy transcode, a large library scan or a big model load.
โ ๏ธ Hazards That Bit During the Rollout
- Stale netavark DNAT rules. Recreating a container can leave a second rule pointing at the old container address. It sorts first and the port times out. Check
nft list ruleset | grep dnatafter every recreate and compare targets withpodman inspect. A container on two networks legitimately has two rules. - The above has caused considerable problems since the 29th October due to dockhand updating containers that are not version fixed. To be very honest this has caused considerable work on the installation script of the production LXC, and the configuration of netavark. So much so that a docker alternative script has been drafted to purge Podman. Investigation on going, but at the moment all appears stable, and is behaving. It is NOT related to anything within this post, but worth meantioning.
- Dead conmon after a long uptime. A whole-stack
up -dcan end in "conmon exited prematurely". Go one container at a time: stop, remove, thenup -d --no-deps <service>. - GPU (CDI) containers. docker-compose over the Podman socket can't create them (it fails on
nvidia.com/gpu=all). My deployment manager's API path can. - Redeploys touch more than you changed. A redeploy through the deployment manager can recreate every service in a stack. The media server was recreated along with the rest.
๐๏ธ The Jellyfin Confession
I deliberately left Jellyfin unlimited at first. It's a GPU container, and I feared a limit would cause a playback outage. On 6 Nov it got 2g and redeployed healthy with its GPU devices. No problems so far, but no transcode load test either. My own design notes still say "no limit", so those need correcting.
The deployment manager is the other loose end. Its 768 MB limit is in my provisioning script but not live yet.
Deliberately still unlimited: a few sandbox services (a documented exception) and some switched-off services in the blog stack.
๐งฉ Summary
Key takeaways:
- Measure working set, not cache.
podman statsalone will mislead you - Size at roughly 2-4ร the measured max, more for JVM, .NET, GPU and transcoding
mem_limitis the key I tested;deploy.resources.limits.memoryI did not- Deploy one stack at a time, stop first, and check DNAT, conmon and OOM counters after each
- Treat averaged monitoring data as a floor, not a peak
๐งฉ Final Verdict (Revised)
The original post ended with an AI telling me:
There are no other containers that need memory limits or tuning.
It called my fleet "absurdly lean". It was a confident summary of a single podman stats snapshot, and it was wrong. Before 24 Oct every container had no limit. On 6 Nov, eighteen long-running services still had none, including the deployment manager and both LLM containers.
An AI summary of one snapshot is not an audit. The method above is.
I have not checked since moving to Dockhand to manage my containers if this is a suitable replacement for the stats that Beszel gives. However it should be investigated at a later date, but not today.
Live and learn.
#enoughsaid