We have an a medium-big asp.net project on dotnet 6. Newtonsoft.JSON and efcore 5 are used.
It's hosted on linux containers governed by k8s on aws.
We're seeing the nodes dying out once in a day or two due to memory issues, they have 4GB RAM available.
When doing memory profiling I've noticed a strange accumulation of instances of RuntimeTypeHelper
, GenericFieldInfo
, and RuntimeMethodHandler
in Generation 2, hundreds of thousands of them after just running locally and navigating thought ~10-20 pages of the application several times over and over. The pages are data-rich, yes, but anyway a steady linear increase in the retained objects count is suspicious.
dotMemory shows they are retained through ServiceProvider
and sampling couple of them, they have some pretty obscure creation stack trace
I've tried migrating everything to dotnet 7, updating all the libraries and switching to System.Text.Json, that didn't noticeably change the overall picture.
What could be the reason for such objects accumulation? Or conversely, is this normal and I should rather focus on memory pressure and look into decreasing allocations elsewhere?