If your web application showing OutOfMemoryException error, the first thing to check for more details is the Event Viewer logs. You should see which function is throwing this exception in the stack trace of the error. In the case I worked on, a variable in StringBuilder type was the root cause of this exception.
Checki the Private Memory Limit first. Make sure there is no limit specified or the limit entered is high enough for the web application to work properly. In order to check this feature, go to “Advanced Settings” of your application pool:
If IIS settings look good, it’s time to look into your code. There are three main causes of OutOfMemoryException related to the usage of StringBuilder (Reference)
If the root cause is still not clear, use DebugDiag to collect a dump. You can use DebugDiag to collect crash log, performance log, or memory leak log. In this case, collect crash log since the application is crashing with “out of memory” error.
Note: It’s not common but DebugDiag itself may cause performance issue in the server. I recommended running it for a specific period time and deactivating the rule once you collect dump files.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.