a不能自动释放,如果这样就会造成内存泄漏,所以要在Form的OnDestroy事件里
a.Free;
a.Free;
解决方案 »
- CxGrid如何禁止右键选定?或者如何捕获右键动作?
- 一个关于socket传送数据包的问题(急)
- ehlib3.2控件中的DBGridEh,如何设置下拉式菜单(类似于COMBOBOX控件的效果)?
- OUTPUT参数问题??请高手帮忙看一下!!!
- 这个问题如何解决?
- if(full)可以表示当前窗口的全屏幕状态吗?如果用=ture语句可能吗?
- ADO控件本身是否线称安全?
- 100分
- 如当我为表田数据的时候,我想让qt_id自动增加,不用手工添加(我的数据库是sql),我用table连接表的,编程方法怎么写
- 调用api实现关机、重启、黑屏、鼠标控制的问题
- 在线等待,数据变量怎样赋值给数据字段,急
- 请问做一个在线的接收Email的软件, 怎么判断已经邮箱中已经有新的邮件?
>>在窗体关闭后,这个对象a是否能自动释放内存!!!
窗体关闭(只是form.hide)并不意味这窗体释放,如果窗体释放了(form.free),父亲是这个窗体的对象当然也会释放的。
>>在窗体关闭后,这个对象a是否能自动释放内存!!!
窗体关闭(只是form.hide)并不意味这窗体释放,如果窗体释放了(form.free),父亲是这个窗体的对象当然也会释放的。
Try
.....
Finally.
这样就不会出问题了。我认为自己创建的对象就一定要自己释放。
自己的事情自己做吗。
TObject.Free
Destroys an object and frees its associated memory, if necessary.procedure Free;DescriptionUse Free to destroy an object. Free automatically calls the destructor if the object reference is not
nil. Any object instantiated at runtime that does not have an owner should be destroyed by a call to Free so that it can be properly disposed of and its memory released. Unlike Destroy, Free is successful even if the object is nil; so if the object was never initialized, Free won抰 result in an error.When you call Free for a component, it calls Free for all components that it owns梩hat is, all components in its component list. Since a form owns all the controls and nonvisual components that are created on it in design mode, those components are automatically freed when the form is freed. By default, all forms are owned by the Application object; when the application terminates, it frees the Application object, which frees all forms. For objects that are not components, or for components created with a nil owner, be sure to call Free after you are finished with them; otherwise the allocated memory will not be usable until after the application terminates.Warning: Never explicitly free a component within one of its own event handlers or the event handler of a component it owns or contains. For example, don抰 free a button, or the form that owns the button, in its OnClick event handler.To free a form, call its Release method, which destroys the form and releases the memory allocated for it after all its event handlers and those of the components it contains are through executing.看一看这句话:
When you call Free for a component, it calls Free for all components that it owns--that is, all components in its component list.