在这个c#EF场景中我是否需要担心垃圾收集?

ast*_*ght 2 c# memory-leaks exception-handling using

try
{
  using (MapDataContainer ent = new MapDataContainer()) //is an autogen'd EF object
  {
     //do some stuff, assume it throws an error
  }
}
catch(Exception ex) //catching outside using not sure if IDispose called
{
  //handle error
}
Run Code Online (Sandbox Code Playgroud)

通常我理解在EF对象上使用称为IDispose.所以假设它抛出一个异常......这是一个可能的内存泄漏情况吗?

500*_*ror 6

你没事."使用"实际上是一种尝试......最终是伪装.