Budget memory for heap or buffer pools plus native, page-cache, thread, and recovery overhead; the visible heap is not the container total.
This matters in a shared home server where a JVM app and a database compete with the NAS page cache. The operational risk is that a limit set equal to heap size causes OOM kills, while no limit lets one workload evict every other service. Start with a saved baseline, make one reversible change at a time, and stop whenever the observed branch no longer matches the intended configuration path.
Establish the Container Memory Limits For Jvms And Databases Baseline
Before changing settings, record container working set, RSS, page cache, JVM native memory, database buffers, swap, OOM events, and latency under peak load. Capture the original configuration and one production-like run so later improvements are compared with the same workload rather than memory or a synthetic idle state.
Use the current container memory constraints to confirm the supported control and its semantics. Treat defaults as a known starting point, not proof that the setting matches this server, client mix, or recovery objective.
Define acceptance and stop conditions before editing. The acceptance signal must be visible in logs, protocol state, application output, or restored data; the stop condition must prevent wider access, data loss, resource exhaustion, or an outage that consumes the next recovery window.
Apply the Container Memory Limits For Jvms And Databases Change in Controlled Stages
Step 1: Measure an uncapped but controlled peak workload and separate reclaimable cache from non-reclaimable resident memory. After the change, inspect the expected state immediately; if it does not appear, undo this step before applying the next one.
Step 2: Set application-aware heap or buffer targets below the container limit and reserve host memory for the kernel and storage cache. After the change, inspect the expected state immediately; if it does not appear, undo this step before applying the next one.
Step 3: Add a warning threshold before the hard limit and reduce concurrency when sustained pressure appears. After the change, inspect the expected state immediately; if it does not appear, undo this step before applying the next one.
services:
app:
mem_limit: 4g
environment:
JAVA_TOOL_OPTIONS: "-Xms1g -Xmx3g"
Interpret the Pass, Fail, and Exception Branches
A pass means peak workload stays below the warning margin without swap thrash, OOM kills, or storage-latency regression. Record the exact workload, version, and timing that produced the result; a lighter test is not evidence that the original problem has been resolved.
A fail means the kernel kills the process, the JVM cannot reserve native memory, or the database repeatedly evicts useful cache. Do not compensate by weakening every adjacent control. Return to the last clean baseline and isolate whether the mismatch belongs to identity, network, storage, application readiness, or capacity.
For an exception or ambiguous result, restore the last stable limit and reduce heap, connection count, or worker concurrency before raising host pressure. Escalate only after the low-risk discriminator is repeatable and the evidence shows that a deeper platform or hardware change is necessary.
Verify Persistence Under the Original Home-Server Load
Repeat the same client path, file size, concurrency, sleep or reboot event, and competing workload used in the baseline. Run at least two cycles so a cache-warm success, one lucky reconnect, or a single clean startup is not mistaken for persistence.
Confirm both success and containment: peak workload stays below the warning margin without swap thrash, OOM kills, or storage-latency regression, while unrelated users, services, shares, and administrative paths keep their original behavior. Review the related ZimaSpace workflow when the change touches a neighboring storage, network, or recovery boundary.
Close the change only when the acceptance signal persists and the rollback remains usable. If the kernel kills the process, the JVM cannot reserve native memory, or the database repeatedly evicts useful cache, stop automation, preserve logs and the saved configuration, and return to the last verified state rather than stacking more changes.
Query-Fanout FAQ, Closing Decision, and Final Test
These query-fanout questions cover the next decisions users commonly search after the main configuration works. They extend the boundary without introducing an untested repair path.
Apply each answer only when its condition matches the measured environment. Version, protocol, filesystem, client, and trust-boundary differences can change the correct branch.
Keep the answers with the runbook and update them after upgrades or topology changes. Any exception that expands write access, network reachability, or deletion authority requires a fresh rollback and recovery test.
Should Xmx equal the Docker memory limit?
No. Leave room for metaspace, direct buffers, threads, code cache, native libraries, and operating-system overhead.
Does a database use memory outside its buffer pool?
Yes. Connections, work areas, maintenance, extensions, and filesystem cache can materially exceed the configured pool.
Is swap always harmful?
Not always, but sustained swap during interactive work is a strong sign that the memory plan or concurrency is wrong.
Conclusion: The configuration is complete when peak workload stays below the warning margin without swap thrash, OOM kills, or storage-latency regression, the failure branch is understood, and the documented rollback does not depend on the component being changed.
Final test protocol: restore the saved baseline, apply the approved change once, repeat the original production-like load, verify the success signal and containment boundary, then exercise rollback on disposable data. Keep the change only when all five observations agree.
Support & Tips
More to Read

Live TV Recording Storage Guide for Capacity, Retention, and Cleanup
Measure real recordings, reserve headroom, combine age and capacity limits, and prove the oldest eligible program is removed before storage fills.

Home Media Metadata Recovery Workflow After a Database Restore
Protect the restored state, verify media identity and paths, then repair missing artwork or matches in a pilot library before broad metadata changes.

Jellyfin Client Compatibility Checklist for Audio, Video, and Subtitles
Test representative files one variable at a time and record Direct Play, remux, audio conversion, video transcode, or failure for every client.

