最好是你自己用完的时候,显式的释放,这样子最安全,也是好习惯
程序结束时,Owner会帮你释放,如果你还没有释放的话。但是这样子不是好习惯
参考:
TComponent.Owner
Indicates the component that is responsible for streaming and freeing this component.
property Owner: TComponent;
Description
Use Owner to find the owner of a component. The Owner of a component is responsible for two things:
The memory for the owned component is freed when its owner's memory is freed. This means that when a form is destroyed, all the components on the form are also destroyed.
The Owner is responsible for loading and saving the published properties of its owned controls.
By default, a form owns all components that are on it. In turn, the form is owned by the application. Thus when the application shuts down and its memory is freed, the memory for all forms (and all their owned components) is also freed. When a form is loaded into memory, it loads all of the components that are on it.
The owner of a component is determined by the parameter passed to the constructor when the component is created. For components created in the form designer, the form is automatically assigned as the Owner.
Warning: If a component has an Owner other than a form or data module, it will not be saved or loaded with its Owner unless you identify it as a subcomponent. To identify a component as a subcomponent, call the SetSubComponent method.