I'm getting the following error on my production servers:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
It doesn't happen all the time, but seems to happen most frequently during times of high traffic.
The error is occurring in a custom IHttpHandler
.
The stack trace doesn't give much of an indication of what's actually going on when the exception happens - all that is happening in the area it indicates is writing to the response using Response.Write.
I've noticed that when this starts happening, if I remove the traffic from the server, recycle the app pool, and put it back on, it seems to help. Though, when the traffic is first returned, there is a cluster of these errors before it begins working properly.
I've also taken a look through the dozens of other SO questions/ google search results with this error, but none of the remedies seem to be relevant to this situation.
Edit: I don't do anything directly with unmanaged/unsafe code. I do use MEF though, and I'm not sure if it does.