c#清理释放内存

虽然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();

 

你可能感兴趣的:(ArcEngine,c#)