csharp
csharp copied to clipboard
Memory Leak with aot package ListDeployments and ListStatefulSet
Describe the bug SlimFaas is calling ListDeployments and ListStatefulSet every Second (in the futur we will use watch). I think of memory leak because memory increase without ending. Previous version worked on production without any crash with 180Mo of RAM set and the same code. The only change is the switch to AOT packages.
If I remove calls, the memory keep very stable.
https://github.com/AxaFrance/SlimFaas/blob/main/src/SlimFaas/ReplicasSynchronizationWorker.cs https://github.com/AxaFrance/SlimFaas/blob/main/src/SlimFaas/Kubernetes/KubernetesService.cs
All RAM goes down in the graph bellow are OOM Killed.
Kubernetes C# SDK Client Version "KubernetesClient.Aot" Version="13.0.12"
Dotnet Runtime Version .NET 8
Is it possible to analyze some memory info from a dump?
Think the HttpRequestMessage
/HttpResponseMessage
and the HttpContent
should be disposed, maybe we could try to add using
for them firstly
Hi fixed it in my side by this commit https://github.com/AxaFrance/SlimFaas/commit/d71b2ba065f416ae22bd0340407c928e9226e051
But it is still a bug it seem dispose does not dispose well.
I will try to memory dump.
yes dump please i will try to repo by calling list
I had a add week, i will try to do it next week!
i ran the load test last weekend for whole afternoon, but did not see any leak. code is simple
for(;;) { listdeployment; sleep 5s}
my test code
using k8s;
var config = KubernetesClientConfiguration.BuildDefaultConfig();
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");
for (; ;){
var list = client.AppsV1.ListDeploymentForAllNamespaces();
foreach (var item in list.Items)
{
Console.WriteLine(item.Metadata.Name);
}
Thread.Sleep(5000);
GC.Collect();
}
Hi @tg123 @WeihanLi
I was creating disposing a new Kubernetes client at each iteration.
I still have now a tigth memory leak. 10 Mo in 2 productions week. But i have to investigate to know the source.