How does memory management in Java and C# differ?

Posted by David Johnstone on Stack Overflow See other posts from Stack Overflow or by David Johnstone
Published on 2010-03-17T03:22:42Z Indexed on 2010/03/17 3:31 UTC
Read the original article Hit count: 326

I was reading through 2010 CWE/SANS Top 25 Most Dangerous Programming Errors and one of the entries is for Buffer Copy without Checking Size of Input. It suggests using a language with features to prevent or mitigate this problem, and says:

For example, many languages that perform their own memory management, such as Java and Perl, are not subject to buffer overflows. Other languages, such as Ada and C#, typically provide overflow protection, but the protection can be disabled by the programmer.

I was not aware that Java and C# differed in any meaningful way with regard to memory management. How is it that Java is not subject to buffer overflows, while C# only protects against overflows? And how is it possible to disable this protection in C#?

© Stack Overflow or respective owner

Related posts about c#

Related posts about java