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#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 82,061 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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.