虽然c#具有内存管理和垃圾回收机制,但是在arcobjects二次开发嵌入到arcgis data reviewet还会报内存错误。需要强制清理某变量内存方法如下:
1设置静态函数ReleaseCom函数
public static void ReleaseCom(object o)
{
try{System.Runtime.InteropServices.Marshal.FinalReleaseComObject(o)};
catch{}
finally{o=null;}
}
2调用如下
ReleaseCom(pFeature);
GC.Collect();