Attempted to read or write protected memory. This is often an indication that other memory is corrupt

P Umarani Santosh (SX/EDC1) 0 Reputation points
2023-02-28T03:49:08.31+00:00

Hi,

I am getting exception "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" when performing specific operation in our application. I am unable to find the root cause or fix the issue.

Please give me some hint where I can fix the issue.

Looking forward to hear from you.

Thanks,

Santosh

Developer technologies .NET .NET Runtime
Developer technologies C#
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-02-28T21:07:24.24+00:00

    this is generally caused by unmanned code. typically classes that access unmanned code or memory implement Dispose().

    you will want to learn to do heap analysis. the tools will depend on the runtime version:

    https://learn.microsoft.com/en-us/dotnet/core/diagnostics/sos-debugging-extension


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.