怎么样在close一个form的时候把申明在private内的一个OBJ:TOBJECT对象所占的内存释放?我在close事件中写:inherited; Action := caFree;我在TFORM1.Destroy
方法中:OBJ.FREE;
但是我注意了一下:Destroy方法并没有执行?怎么回事?

解决方案 »

  1.   

    你的OBJ创建了吗?
    OBJ:=OBJ.CREATE;
      

  2.   

    function PMCreateOutCusForm(AOutBound_Cus:TOutBound_Cus;AOwner : TWinControl) : TOutCusForm;
    begin
    Result := TOutCusForm.Create(Application);
             Result.BorderStyle := bsNone;
             Result.Parent := AOwner;
             Result.Align := alClient;
    Result.Show;
    end;constructor TOutCusForm.Create(AOwner : TComponent);
    begin
            inherited;
            OutBound_Cus := TOutBound_Cus.Create;end;destructor TOutCusForm.Destroy;
    begin
            OutBound_Cus.Free;
    inherited;
    end;procedure TOutCusForm.CancelOutBtnClick(Sender: TObject);
    begin
            Close;
    end;procedure TOutCusForm.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
           inherited;
    Action := caFree;
    end;每次调用PMCreateOutCusForm方法创建form,点击CancelButton按钮close掉Form...
      

  3.   

    caFree The form is closed and all allocated memory for the form is freed.
    应该没有问题
      

  4.   

    对象不是new出来的,不用释放。