Add GC hints to prevent memory leaks from large byte arrays

This commit is contained in:
2026-02-04 22:50:35 -05:00
parent 1601b96800
commit 07844cc9c5
3 changed files with 109 additions and 9 deletions

View File

@@ -39,6 +39,12 @@ public class SubsonicProxyService
var body = await response.Content.ReadAsByteArrayAsync();
var contentType = response.Content.Headers.ContentType?.ToString();
// Trigger GC for large files to prevent memory leaks
if (body.Length > 1024 * 1024) // 1MB threshold
{
GC.Collect(2, GCCollectionMode.Optimized, blocking: false);
}
return (body, contentType);
}