Background
I recently came across an out of memory exception when users would visit few pages of my Kentico website. Fast forward - I found that the allocated memory (System > General) was over 2 GB! I then went to Debug > Clear cache and then noticed the allocated memory sitting roughly around 400 MB (phew..). Now, when the users would visit the page, it would work without any out of memory exception.
Question
Is there a way I could get these memory statistics via code (ideally C#)? I'm thinking of being able to regularly monitor these memory statistics and trigger an alert (send an email/post to webhook from my C# code) when the allocated memory gets too high.
Additonal information
- Kentico version 9.0.42, hosted in Azure, scaled to 2 instances.
- The App Service Plan's (in Azure) memory usage was roughly at 50% through out - this rules out setting an alert at that level.
Thanks!