Status
This is a confirmed defect in Octopus Server, and it's fixed. The fix first shipped in build 2026.1.11539, and 2026.1.11542 is the first 2026.1 build on the downloads page that includes it. On the 2026.3 release line, the fix is in 2026.3.4001 and later.
Until you can upgrade, reduce the amount of runbook, release, and package history that each retention run has to process, and make those reductions in small steps.
Affected versions
Octopus Server versions before 2026.1.11539 are affected. The issue was confirmed on 2025.4.10306, and we haven't confirmed the earliest affected version.
No 2025.4 build includes the fix. 2025.4 is out of support, so the fix wasn't backported to it.
On the 2026.3 release line, builds before 2026.3.4001 are affected.
You're most likely to see this on instances with a very large retained history, such as runbooks that run on frequent schedules and keep hundreds or thousands of runs, and where the retention task already runs for a long time or keeps failing to complete.
Symptom
- Octopus Server memory climbs while the Apply retention policies task runs, and keeps climbing until the server runs out of memory or someone restarts the service.
- The Octopus Web Portal slows down or stops responding, and deployments that are running when the service restarts fail.
- The spikes repeat on the retention schedule, which is every 4 hours by default.
- The retention task runs for hours, times out, or fails. Cancelling it can take several minutes.
- Adding RAM to the server delays the problem but doesn't stop the growth.
- The task log stops progressing while it applies retention to a runbook with a large run history.
Confirm retention is the cause
If memory spikes line up with background retention activity, treat the scale of retention cleanup as the primary cause to investigate for this symptom.
- Go to Tasks and filter by the Apply retention policies task.
- Compare the start and end times of those tasks with your server's memory graph. If memory starts rising when a retention task starts and drops when it ends or the service restarts, retention is the likely cause.
- Check the duration of recent retention tasks. Healthy runs usually finish in minutes. Runs that take hours, time out, or get cancelled point to a large backlog.
- Open the task log of a long-running task and note which projects and runbooks it was processing when it stalled. Those are the places to clean up first.
If you need Octopus Support to confirm the cause, capture a series of process dumps as memory grows (for example, at 4 GB, 8 GB, and 12 GB). A dump captured at peak memory is often incomplete, because the server can fail before the dump finishes.
Why it happens
Octopus Server runs the Apply retention policies task on a schedule. In affected versions, when that task deletes large numbers of runbook runs or runbook snapshots, the server holds on to a large amount of memory for as long as the task runs instead of releasing it as it goes. On an instance with a large retained history, the task can run for hours, so memory keeps climbing until the server becomes unresponsive.
This can turn into a cycle. Retention evaluates items before it deletes them, so a run that fails, times out, or is stopped by a service restart may delete little or nothing. The next run starts with the same backlog plus anything added since, and the spike repeats.
This is a product defect, not a configuration mistake. A large history, or a change that suddenly increases how much retention has to delete, makes it more likely to appear. Other work running at the same time, such as health checks, package re-indexing, and large deployments, adds pressure but isn't the cause.
Workaround
Upgrading is the fix. Until you can upgrade, the goal is to shrink the work each retention run has to do.
Make every change gradually. A large drop in a retention policy creates a large batch of deletions in a single run, which is what triggers this issue. Before you delete anything, check whether your organization has audit or compliance requirements for keeping deployment and runbook history.
Reduce runbook retention in small steps
- Each runbook has its own retention policy under Project -> Runbooks -> [runbook] -> Settings -> Retention Policy. The default keeps 100 runs per environment.
- From Octopus 2025.4, you can set a default runbook retention policy for a space under Manage -> Retention -> Runbook Retention. This is behind a feature toggle, so contact support if you don't see it.
- Start with the runbooks that run most often. A runbook triggered every few minutes builds up thousands of runs quickly.
- Lower the value a little at a time and wait a day between changes. After each change, check the next retention task log to confirm the task completes and deletes items.
For details, see runbook retention policies.
Remove history you don't need through the API
- Delete runbook runs, runbook snapshots, releases, or whole projects you no longer need through the Octopus REST API, in small scripted batches. The API reference for your instance is at
https://<your-octopus-url>/swaggerui. - If a project with a very large runbook history won't delete from the Octopus Web Portal, try deleting it through the API.
- Test your script against a copy of your database first, so you can be sure it doesn't remove anything recent.
- Don't delete records directly in the database. Octopus manages related records when it deletes something, and a direct SQL delete can leave your database in an inconsistent state.
Set release and package retention
- Release retention: If your lifecycles keep all releases, or a very high number, lower the policy in steps and wait a day or two between changes. For example, if a lifecycle has about 2,000 releases, start at 1,700, then 1,400, and so on. Change one lifecycle at a time, then set the default lifecycle retention policy so new lifecycles inherit a sensible value.
- Package retention: Set the built-in feed retention policy to a number of days instead of keeping packages forever. Octopus never deletes a package that a retained release still uses, so package retention and release retention work together. You don't need to reduce this one in steps.
For details, see retention policies.
Reduce other load while retention runs
- Schedule machine policy health checks so they don't overlap with retention runs. There's no setting that pauses health checks during retention, so offset their schedule from the retention schedule.
- Re-index packages one space at a time, during off-peak hours.
- Avoid scheduling large deployments in the same window as retention.
Maintain the database
Index fragmentation can make retention slower and more likely to time out. Ask your database administrator (DBA) to check index fragmentation in the Octopus database, for example with the Index Physical Statistics standard report in SQL Server Management Studio, and to follow the Octopus SQL Server maintenance guidance. If you'd like the exact diagnostic queries Octopus Support uses, contact Octopus Support and we'll send them to you.
Rebuild any indexes with high fragmentation. Aim for less than 50% on every table, and closer to 30% on large databases. Octopus also rebuilds indexes when you upgrade. If you're working through a large backlog, consider adding SQL Server resources temporarily until retention runs complete reliably.
What doesn't help
- Automatic service restarts: A monitor that restarts Octopus Server at a memory threshold keeps the server available, but it stops the retention task before it finishes, so the backlog never clears. If you need one to keep the server responsive, expect retention to keep failing until you've reduced the backlog or upgraded.
-
.NET garbage collection settings: Settings such as
DOTNET_GCConserveMemorymay soften the peaks, but they don't address the cause. - More RAM on its own: Extra memory buys time, but the growth continues for as long as the task runs.
Fix
Upgrade to one of these versions or later:
- 2026.1.11542 (the fix first shipped in 2026.1.11539)
- 2026.3.4001
Once you've upgraded, retention can delete large numbers of runbook runs and runbook snapshots without the memory growth, so the task can finish and work through the backlog. The upgrade also rebuilds your database indexes. The first few retention runs after the upgrade may take longer than usual while they clear the backlog.
Before you upgrade production, review the breaking changes between your current version and the target version on the compare releases page, and test the upgrade on a test instance that uses a copy of your production database.
If memory still climbs after you upgrade
The fix covers runbook runs and runbook snapshots. Release retention can still use a lot of memory on instances with very large numbers of releases and packages, especially where lifecycles keep all releases.
Check the Octopus Server log for the scope and result of each retention run:
2026-09-25 01:20:21.7359 3832 155 INFO ApplyRetentionPolicies scope: 3787 policies covering 1931 projects, 11 lifecycles, 3787 channels; 185029994 packages used by releases, 174254 packages used by runbooks; 1934 releases on dashboard, 3122 previous releases
2026-09-25 01:57:32.5522 3832 82 INFO Release retention finished "Completed" in 2230002ms: 0 releases deleted, 3787 of 3787 policies processed
A very large packages used by releases count, together with runs that complete but report 0 releases deleted, means retention is calculating over your full history without being allowed to delete anything. This usually means your lifecycles keep all releases. Set release and package retention as described in Workaround, and make sure the server has enough memory headroom to run retention alongside its normal workload.