OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.43k stars 2.4k forks source link

CMS take too much memory #9998

Closed hoanghai1212 closed 5 months ago

hoanghai1212 commented 3 years ago

Describe the bug

I published release version of CMS and deploy to my EC2, every still okay but today when I checking my EC2 status, I see Orchard take too much memory as an web application. (over 700mb).

Screenshots

If applicable, add screenshots to help explain your problem. image

This is normal or something not going right ?

deanmarcussen commented 3 years ago

Is it possible you are using the app in Development mode?

Please check your deployed ASPNETCORE_ENVIRONMENT variable.

Also please provide the version of Orchard Core you are using

hoanghai1212 commented 3 years ago

Please check your deployed ASPNETCORE_ENVIRONMENT variable.

I don't found an variable with that name in my publish folder. Also please provide the version of Orchard Core you are using I use latest version 1.0.0

deanmarcussen commented 3 years ago

Is it possible you are using the app in Development mode?

Please check your deployed ASPNETCORE_ENVIRONMENT variable.

Try logging the ASPNETCORE_ENVIRONMENT in a Layout view or something. It is pretty common for people to use the Development environment variable and run into issues like this. Try setting it specifically to Production

hoanghai1212 commented 3 years ago

Production

Okay I'll try this

Skrypt commented 3 years ago

Should be normally around 300 mb from fresh install of a single tenant.

sebastienros commented 3 years ago

It also depends on the amount of memory your server has. If the total is 1GB there could be a problem. If it's 16GB it's might actually be normal, the GC not freeing the memory because it doesn't have to.

hoanghai1212 commented 3 years ago

I redeploy latest version and it take around 300Mb like Skrypt mention before, today I check it again it take 450Mb, maybe it's take more memory by the time. My server only have 2gb of RAM. I use ec2 ubuntu 20.04 by the way

FinnurHrafn commented 3 years ago

I am running the Docker Hub Linux v1.0.0/Latest image on Azure App Service which returns normally less than 300 MB of memory: image

FinnurHrafn commented 3 years ago

Docker Desktop on my local machine reports 700-800 MB so I am not sure what gives: image Maybe it has something to do with that the Azure App Service VM has only 1,5GB but my desktop 16GB with several GB dedicated to WSL2. The working set size tends to be bigger when a lot of memory space is available.

hoanghai1212 commented 3 years ago

after few day it's take more memory again. image

Skrypt commented 3 years ago

Like Sebastien said, the memory is probably not disposed by the garbage collector because it doesn't need to. Over time, some operations on the website could cause the memory usage to go up. The question is : does it make your Docker container unusable or not? If you limit your container to 2 gb it can use it all if it requires to. If it starts to slow down because it seems to require more than the limit then it's because the website does something that requires it. What you should try to know then is : what makes the memory usage goes up and also "when".

hoanghai1212 commented 3 years ago

For now I'm not using Docker to run my Orchard anymore I just run it directly in my ec2 as an system service. It not slowing down my website although it take a lot of memory. Everything still ok for now but I'm not sure in the future so my solution is setting a crontab job to restart my Orchard service every day.

Skrypt commented 3 years ago

I'm using an Azure App and it sits at around 700 mb. Never had an issue and never needed to reboot the website periodically. Maybe, that's just how much memory it reserves for OC to run. I'd feel concerned if it was making the application crash because the memory would grow and require to use disk swapping to run. But, else, it just takes more ram because it can ...

Piedone commented 5 months ago

Since then, we've fixed multiple memory leaks and optimized memory usage a lot. Please open a new issue with specifics if the problem persists.

sebastienros commented 5 months ago

There is a new GC mode in .NET 8.0 that should be tested, by setting this ENV: DOTNET_GCDynamicAdaptationMode=1

This should improve the overall memory usage while not impacting the perf visibly.

Piedone commented 5 months ago

Interesting, thanks for the tip, we'll try this!