在C#中实际发生的事情是:
1) A method gets invoked.
2) The method allocates memory (e.g. MemoryStream mm = new MemoryStream()).
3) An exception occurs in the method which is caught by the invoking classes.
Run Code Online (Sandbox Code Playgroud)
资源"mm"是否被垃圾收集器释放?这是安全风险(例如DoS)吗?
PS:我知道最好的做法是明确地释放任何已分配的资源.这意味着使用"using"-statement或"try/catch/finally"-block.