Halcon与C#联合编程时的内存回收机制
来源:互联网 发布:处理数据 英文 编辑:程序博客网 时间:2024/06/05 15:10
摘自halcon文档:
The .net philosophy is to let the garbage collector remove unused objes. However, because the garbage collector detects unused objects only from time to time, the used memory increases in the meantime. Even more important is that, to the garbage collector, Halcon's iconic variables(image,regions,...) seem to be rather "small",because they only contains a reference to the (in many cases rather large) iconic objects in the database. Thus ,the garbage collector may free such variables even if they are not used anymore.
Therefor, you need to force the removal of (unused) objects. There are two ways to do this:
1) Call the garbage collector mannually . In the example Matching ,this is done after each processing run in the timer event:
private void Timer_Tick(object sender, System.EventArgs e)
{
Action();
GC.Collect();
GC.WaitForPendingFinalizers():
}
C++ applications
GC::Collect():
GC::WaitForPendingFinalizers();
2) Dispose of individual objects manually by calling the method Dispose:
HImage Image = new HImage("fuse");
...
Image.Dispose():
Please note that Halcon operators always create a new object instance for output parameters and return values(but not in the "constructor-like" operator calls that modify the calling instance). If the variable was already initialized,its old content( and the memory allocated for it ) still exists until the garbage collector removes it .If you want to remove it mannualy ,you must call Dispose before assinging an object to it.
总结为一句话:对象在使用前后都需要Dispose():
- Halcon与C#联合编程时的内存回收机制
- C#与Halcon联合编程
- Halcon & C# 联合编程
- Qt与halcon的联合编程
- Qt与halcon联合编程
- c#的内存回收机制。
- Halcon联合C++编程
- Java 与 C++的内存回收机制
- halcon与C#混合编程
- Java与C#的垃圾回收机制
- Java与C#的垃圾回收机制
- Java与C#的垃圾回收机制
- Java与C#的垃圾回收机制
- Java与C#的垃圾回收机制
- Java与C#的垃圾回收机制
- Java与C#的垃圾回收机制
- JVM垃圾回收机制与内存回收
- STK与C#联合编程
- GROUP BY分组查询与SQL执行顺序
- 第一篇博客,处女作
- Android 不让EditText自动获取焦点
- jsp通过<img>标签的src属性来调用servlet类生成验证码遇到的问题
- JS闭包函数和回调函数
- Halcon与C#联合编程时的内存回收机制
- 面试题4:替换空格
- Android7.0调用系统相机奔溃问题
- python 多维数组(array)排序
- 堆和栈, 他们是什么?
- python3爬虫攻略(9):requests的使用
- [BZOJ2208][Jsoi2010]连通数(tarjan+topdp)
- C++编译链接
- map,reduce,filter之python2,python3区别