Delphi中须注意的二个对象(TStreamAdapter、TObjectList)的释放问题
来源:互联网 发布:手机丢了淘宝怎么冻结 编辑:程序博客网 时间:2024/04/30 06:09
TObjectList对象的创建方法有一个参数:
constructor TObjectList.Create(AOwnsObjects: Boolean);
从字面就可理解其意义:拥有对象集与否。帮助文档:
If the OwnsObjects property is set to true (the default), TObjectList controls the memory of its objects, freeing an object when its index is reassigned; when it is removed from the list with the Delete, Remove, or Clear method; or when the TObjectList instance is itself destroyed.
这段话的意思就是TObjectList 的几个删除方法和释放方法都受参数AOwnsObjects的影响。我就常常用 TObjectList来管理对象,很方便。记得第一次用时,没看文档,用的默认参数值,重载其释放方法,结果一直报错,因为在DLL中实现,找了很久才找出缘由。
TStreamAdapter对象的创建方法也有一个类似的参数
constructor TStreamAdapter.Create(Stream: TStream; Ownership: TStreamOwnership);
当Ownership参数为soOwned时,则适配器释放时会释放其对应的具体流实例。
constructor TObjectList.Create(AOwnsObjects: Boolean);
从字面就可理解其意义:拥有对象集与否。帮助文档:
If the OwnsObjects property is set to true (the default), TObjectList controls the memory of its objects, freeing an object when its index is reassigned; when it is removed from the list with the Delete, Remove, or Clear method; or when the TObjectList instance is itself destroyed.
这段话的意思就是TObjectList 的几个删除方法和释放方法都受参数AOwnsObjects的影响。我就常常用 TObjectList来管理对象,很方便。记得第一次用时,没看文档,用的默认参数值,重载其释放方法,结果一直报错,因为在DLL中实现,找了很久才找出缘由。
TStreamAdapter对象的创建方法也有一个类似的参数
constructor TStreamAdapter.Create(Stream: TStream; Ownership: TStreamOwnership);
当Ownership参数为soOwned时,则适配器释放时会释放其对应的具体流实例。
- Delphi中须注意的二个对象(TStreamAdapter、TObjectList)的释放问题
- delphi 中由TObjectList对象Destroy引起内存释放的问题
- delphi中TObjectList删除对象
- Delphi中对象释放的问题
- Delphi中对象释放的问题
- Delphi中对象释放的问题
- Delphi 接口使用中,对象生命周期管理,如何释放需要注意的问题。
- Delphi 接口使用中,对象生命周期管理,如何释放需要注意的问题
- delphi 中CreateOleObject函数产生的对象的释放问题
- Delphi容器类之---TList、TObjectList、TComponentList、TClassList的使用
- Delphi容器类之---TList、TObjectList、TComponentList、TClassList的使用
- VC++中GDI对象的释放问题
- ArcEngine中com对象的释放问题
- 含有指针成员的对象的内存的开辟和释放需要注意的问题
- images对象的释放问题
- php5 中, 对象引用的注意问题
- 简单说说Delphi中线程的释放
- Delphi中内存的动态分配与释放
- Delphi中模块句柄管理,及FindClassHInstance详解
- Delphi中的压缩单元ZLib.pas中二个鲜为人知的二个“指针”全局函数CompressBuf()和DeCompressBuf()
- MS-SQL 2000中未公开的Type_name(id)内部函数和Sp_ForEachTable存储过程
- 数据库设计的八条原则
- 我出的几道OO面试题
- Delphi中须注意的二个对象(TStreamAdapter、TObjectList)的释放问题
- Autoconf 学习笔记(2)
- cxGrid作树形控件使用
- javascript用回车键实现Tab键功能
- 无组件不能上传rar,zip非图片文件
- 读《Ajax基础教程》(2)
- Linux下安装JDK以及Tomcat
- Java: JNI完全手册
- windows xp 快速启动栏"显示桌面"图标恢复方法