We have an enterprise application built using server side Blazor and hosted in Azure. With increased app usage, the memory allocation to the app service would just keep climbing until we would get to 90-100% of our allocated memory. Everything we read seemed to indicate we didn't really need to do anything and the normal garbage collection processes would keep things running smoothly.
We started reading things online about folks implementing IDisposable on their pages to try and clean things up. We tried a few things and nothing really seemed to help until we did a memory analysis using Visual Studio's analytics. We noticed that large lists of data were not released from the heap and the data grids that used this data were also not being released.
So, we went through the whole app and implemented IDisposable on all pages and any components that used data grids and contained large lists of data. In the Dispose methods be cleared all data and nulled out any data grids that used the data. Also as a bit of over kill we requested a garbage collection as well.
Results
Prior to this change, normal resting state of the app was around 40-50% memory used and would jump to 90-100% used when the app was active.
After the IDisposable implementation, resting state of the app sat around 20-25%, and maxed out at just less than 35%.
This was a truly remarkable outcome. Please tell me this is all wrong or tell me about your successes as well so we can help others with this issue.
We implemented IDisposable and it worked.