Memory leak with KubernetesClient
While running YARP as ingress controller we see overall raising pattern of memory consumption and frequent restarts due to hitting pod limits.
To Reproduce
Run release/2.1/samples/KubernetesIngress.Sample/Ingress sample ingress for a breif while (10-15 minutes).
Get a GC Dump.
Issue has a signature / related to: https://github.com/kubernetes-client/csharp/issues/1123 Present in KubernetesClient.Basic v.9.0.28. Fixed in KubernetesClient.Basic v.10.0.1
Further technical details
- YARP Version: 2.1.0
- Platform/base image: mcr.microsoft.com/dotnet/aspnet:8.0.3-bookworm-slim-amd64
I started using YARP v.2.2.0-preview.1 (where KubernetesClient is update to v.10) and pattern of GC dumps have changed. Problem is not fully resolved, service continues to increse RAM usage daily. Here is comparison though 26 hours: one of the most numerable objects is CancelationTokenSource.
Also not sure, if such report would indicate a cyclic dependecy that prevents garbage collection:
Thanks for raising the issue. It'd make sense for us to move to the more recent KubernetesClient version with the fix.
Presumably this isn't an issue anymore?
We've moved to 10.1.19 in https://github.com/dotnet/yarp/pull/2338 (December 2023), and we're currently referencing 15.0.1
https://github.com/dotnet/yarp/blob/a91669145d395eb33f16d4c397a90a51c735d1d0/eng/Versions.props#L34