a不能自动释放,如果这样就会造成内存泄漏,所以要在Form的OnDestroy事件里
  a.Free;

解决方案 »

  1.   

    largewang(老王) ,看清楚题目:
    >>在窗体关闭后,这个对象a是否能自动释放内存!!!
    窗体关闭(只是form.hide)并不意味这窗体释放,如果窗体释放了(form.free),父亲是这个窗体的对象当然也会释放的。
      

  2.   

    largewang(老王) ,看清楚题目:
    >>在窗体关闭后,这个对象a是否能自动释放内存!!!
    窗体关闭(只是form.hide)并不意味这窗体释放,如果窗体释放了(form.free),父亲是这个窗体的对象当然也会释放的。
      

  3.   

    保险的办法是用
    Try
    .....
    Finally.
    这样就不会出问题了。我认为自己创建的对象就一定要自己释放。
    自己的事情自己做吗。
      

  4.   

    如果你的TStringList是声明为窗体的成员,则窗体释放的时候,TStringList也会跟着释放,如果不是窗体的成员,则不会释放,你应该在别的地方释放他。详细信息请参考TObject.Free的帮助:
    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.