写前台程序的时候经常遇到自己创建对象的情况,我们知道delphi没有类似Java的内存回收技术,
所以要手动释放自己创建的对象。
大部分对象创建的时候,在create构造函数中都有一个AOwner参数,该参数用来指定对象的owner,
先看一下delphi帮助中对owner属性的解释:
Delphi has a built-in memory-management mechanism that allows one component to assume
responsibility for freeing another. The former component is said to own the latter. The
memory for an owned component is automatically freed when its owner's memory is freed.
The owner of a component梩he value of its Owner property梚s determined by a parameter
passed to the constructor when the component is created. By default, a form owns all
components on it and is in turn owned by the application. Thus, when the application
shuts down, the memory for all forms and the components on them is freed.
Ownership applies only to TComponent and its descendants. If you create, for example,
a TStringList or TCollectio
所以要手动释放自己创建的对象。
大部分对象创建的时候,在create构造函数中都有一个AOwner参数,该参数用来指定对象的owner,
先看一下delphi帮助中对owner属性的解释:
Delphi has a built-in memory-management mechanism that allows one component to assume
responsibility for freeing another. The former component is said to own the latter. The
memory for an owned component is automatically freed when its owner's memory is freed.
The owner of a component梩he value of its Owner property梚s determined by a parameter
passed to the constructor when the component is created. By default, a form owns all
components on it and is in turn owned by the application. Thus, when the application
shuts down, the memory for all forms and the components on them is freed.
Ownership applies only to TComponent and its descendants. If you create, for example,
a TStringList or TCollectio