by Osiris · 15y ago · 0 comments
I know that it's still possible to leak memory in C#, like not releasing event handlers, but it's very difficult, if not impossible, to corrupt memory without using unsafe code. In those cases you're probably more likely to be careful with how memory is used or manipulated anyway to avoid causing corruption with the managed code.
And these are hard to get right, because they are very prone to off-by-one errors, and novice programmers tend to write string manipulation routines from scratch, which leads to corruption.
Use libraries (e.g. bstring or std::string in C++) that do that for you, and you won't have problems.
Regarding memleaks: you can leak database handles, file handles and other resources in managed languages. In C/C++ memory is one of the resources you also take care of. In C++ there are also destructors and you can use RAII to handle most of the cases without thinking.