Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak with aot package ListDeployments and ListStatefulSet #1539

Open
guillaume-chervet opened this issue Mar 10, 2024 · 9 comments
Open
Assignees

Comments

@guillaume-chervet
Copy link

guillaume-chervet commented Mar 10, 2024

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.
image

Kubernetes C# SDK Client Version
"KubernetesClient.Aot" Version="13.0.12"

Dotnet Runtime Version
.NET 8

@WeihanLi
Copy link
Contributor

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

image

@guillaume-chervet
Copy link
Author

Hi fixed it in my side by this commit AxaFrance/SlimFaas@d71b2ba

But it is still a bug it seem dispose does not dispose well.

I will try to memory dump.

@tg123
Copy link
Member

tg123 commented Mar 10, 2024

yes dump please
i will try to repo by calling list

@guillaume-chervet
Copy link
Author

I had a add week, i will try to do it next week!

@tg123 tg123 self-assigned this Mar 24, 2024
@tg123
Copy link
Member

tg123 commented Mar 28, 2024

i ran the load test last weekend for whole afternoon, but did not see any leak.
code is simple

for(;;) { listdeployment; sleep 5s}

@tg123
Copy link
Member

tg123 commented Apr 7, 2024

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();
}


@guillaume-chervet
Copy link
Author

Hi @tg123 @WeihanLi

I was creating disposing a new Kubernetes client at each iteration.

@guillaume-chervet
Copy link
Author

I still have now a tigth memory leak.
10 Mo in 2 productions week. But i have to investigate to know the source.

@tg123
Copy link
Member

tg123 commented Apr 7, 2024

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants