-
Notifications
You must be signed in to change notification settings - Fork 309
Description
Describe the bug
Kubernetes Csharp client has a memory leak problem when using the leader election functionality.
Kubernetes C# SDK Client Version
8.0.4
Server Kubernetes Version
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.8", GitCommit:"83d00b7cbf10e530d1d4b2403f22413220c37621", GitTreeState:"clean", BuildDate:"2022-11-09T19:50:11Z", GoVersion:"go1.17.11", Compiler:"gc", Platform:"linux/amd64"}
Dotnet Runtime Version
.net 3.1 core
Where do you run your app with Kubernetes SDK (please complete the following information):
- OS: Linux
- Environment container
- Cloud Azure
Additional context
Here is my investigation of this memory leak problem.
When we use the leader election functionality, we find that memory increases over time.
The following picture shows that the count of the object named "Linked1CancelaationTokenSource" increased greatly.
The following picture shows the call stack of how the KubernetesClient will call the function named "CreateLinkedTokenSource" to create the object named "Linked1CancelaationTokenSource".
The following picture shows the decompiled code from version 8.0.4 "KubernetesClient.Basic.dll". From the following decompiled code we can see, the "Dispose()" function of the "CancellationTokenSource cts" is not called.