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 after upgrading to .net 9 with large PageSize #1370

Open
valentasm1 opened this issue Dec 9, 2024 · 5 comments
Open

Memory leak after upgrading to .net 9 with large PageSize #1370

valentasm1 opened this issue Dec 9, 2024 · 5 comments
Assignees
Labels
bug Something isn't working P1 regression

Comments

@valentasm1
Copy link

Upgrade project to net9.0 without changing anything. Doing 4th request it consumes ~5gb ram. There is no memory leak with .net8

Just do 4 request to https://localhost:7071/odata/humanentity
Project uses in memory db, but have [EnableQuery(AllowedQueryOptions = AllowedQueryOptions.All, PageSize = 1_000_000_000)] large page size.

Repro repository
https://github.com/valentasm1/Odata9MemoryLeak/tree/main

@valentasm1 valentasm1 added the bug Something isn't working label Dec 9, 2024
@corranrogue9
Copy link
Contributor

@valentasm1 can you clarify, are you only changing the .NET version in your .csproj or are you updating other dependencies with the intent of moving to .NET 9?

Also, it's interesting that you are using such a large page size. Paging is actually disabled by default if you're selecting that page size in order to avoid paging. Can you give some more insight about why you've chosen this page size so we might be able to help you work around the issue while we investigate?

@valentasm1
Copy link
Author

valentasm1 commented Dec 10, 2024

I only change from <TargetFramework>net8.0</TargetFramework> to <TargetFramework>net9.0</TargetFramework> I understand that such large page size look strange, but still it should not consume 5gb of ram. Maybe it is a sign of memory leaking.
I understand that workaround is to remove page size. Probably more right way than workaround.
Issue persist that it a leaks memory with such small requests. It even dont come back after request ended.

@xuzhg
Copy link
Member

xuzhg commented Dec 10, 2024

@valentasm1 Can I set a remote call with you to understand the details? If avaiable , please share a link So I can join it?

@xuzhg
Copy link
Member

xuzhg commented Dec 10, 2024

I use your repro, run the sample and keep eye on Diagnostic tools on Visual Studio:

And I took four snapshots for the memory:

image

  1. After starting up and no request
  2. Send 4 requests
  3. Then waiting couple mins
  4. Then send another 4 requests.

This is the diff between 1 and 2:

image

When first request coming, the ASP.NET Core will finish a lot of configurations so the memory usage is a little bit heavy. Can you point me how do you monitor the memory changes?

@valentasm1
Copy link
Author

TaskManager.
I tried to run it in release mode. It produce same big memory consumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 regression
Projects
None yet
Development

No branches or pull requests

3 participants