Fix OOM in Octopets API by reducing test memory allocation from 1GB to 100MB#2
Closed
Fix OOM in Octopets API by reducing test memory allocation from 1GB to 100MB#2
Conversation
Copilot
AI
changed the title
[WIP] Fix high memory usage in Octopets API
Fix OOM in Octopets API by reducing test memory allocation from 1GB to 100MB
Dec 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Incident INC0010007 reported
System.OutOfMemoryExceptioninListingEndpoints.AReallyExpensiveOperation()whenERRORS=true. The method allocated ~1GB (10×100MB) in a container with 1Gi limit, causing sustained memory plateau at 852-855MB followed by OOM crashes.Changes
Preserves error simulation functionality while preventing container memory exhaustion.
Original prompt
This section details on the original issue you should resolve
<issue_title>[INC0010007] Sev3: High Memory Usage & OOM in Octopets API (Container Apps)</issue_title>
<issue_description>Incident: INC0010007 (Sev3)
Service: Octopets API (Container Apps)
Resource: /subscriptions/06dbbc7b-2363-4dd4-9803-95d07f1a8d3e/resourceGroups/rg-octopets-lab/providers/Microsoft.App/containerApps/octopetsapi
Environment: Sweden Central, latest revision octopetsapi--0000012, image acrey2l3bicrkpwu.azurecr.io/octopetsapi:20251216173840, resources: cpu=0.5, memory=1Gi, min/max replicas=1/3, http-scaler concurrentRequests=10
Alert: High Memory Usage - Octopets API, fired 2025-12-17T17:23:28Z, threshold WorkingSetBytes > 500,000,000 avg 5m
Evidence Summary:
Metrics (WorkingSetBytes, last 45m): plateau at ~852–855MB from 17:19–17:23 UTC; peak 854,720,512 at 17:21; pre-spike mean ~114MB, sustained-high mean ~853MB.
Chart-ready points (UTC|bytes):
16:58:00|103800000;17:15:00|124801024;17:17:00|92792832;17:18:00|472297472;17:19:00|851681280;17:20:00|852680704;17:21:00|854720512;17:22:00|853712896;17:23:00|852989952
Container logs (revision octopetsapi--0000012, 17:17–17:19 UTC): repeated System.OutOfMemoryException in Octopets.Backend.Endpoints.ListingEndpoints.AReallyExpensiveOperation() at /src/backend/Endpoints/ListingEndpoints.cs:line 18; triggered via MapListingEndpoints delegate (line 53). Multiple connections failing in Kestrel.
Excerpt:
System.OutOfMemoryException
at Octopets.Backend.Endpoints.ListingEndpoints.AReallyExpensiveOperation() in /src/backend/Endpoints/ListingEndpoints.cs:line 18
at Octopets.Backend.Endpoints.ListingEndpoints.<>c.<b__1_1>d.MoveNext() in /src/backend/Endpoints/ListingEndpoints.cs:line 53
Suspected Root Cause:
Proposed Code Fix (minimal diff sketch):
Example patch (illustrative):
--- a/src/backend/Endpoints/ListingEndpoints.cs
+++ b/src/backend/Endpoints/ListingEndpoints.cs
@@
@@
IaC/Config Observations & Recommendations:
Repro/Diagnostics:
Action Needed:
Notes:
Links:
This issue was created by sre-agent-lab--755504d1
Trac...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.