UWP项目上的以下代码抛出ObjectDisposedException(针对Windows 10 Anniversary Edition - 14393):
using (var content = new HttpMultipartFormDataContent())
{
//Why disposing of the content raises an exception?
}
异常消息是:Additional information: The object has been closed. (Exception from HRESULT: 0x80000013)
堆栈追踪:at System.Runtime.InteropServices.WindowsRuntime.IClosable.Close()
at System.Runtime.InteropServices.WindowsRuntime.IClosableToIDisposableAdapter.Dispose()
at App3.MainPage.ButtonBase_OnClick(Object sender, RoutedEventArgs e)
这是否意味着尽管HttpMultipartFormDataContent
实现IDisposable
它不应该被处理掉?
如果我不处理HttpMultiparFormDataContent
类型对象,我的应用程序会好吗?
答案 0 :(得分:1)
感谢您报告错误/问题。在上述情况/场景中不调用Dispose,不一定会导致内存泄漏问题,应该回收内存。您可能会注意到内存增加,但不一定是内存泄漏。您可以通过在Visual Studio中启动诊断会话来自行检查(Debug - > Performance Profiler - > Memory)