rt

解决方案 »

  1.   

    要么用nil 要么用assigned() 除此没有!
      

  2.   

    刚刚买了 《Delphi7入门与精通》(Mastering Delphi 7),看了第一章,上面说x=nil 和 x.free 完全是两回事不能通过x:=nil释放对象,必须用x.free
      

  3.   

    freeandnil(ClassObject)释放对象,就可以用Nil判断
      

  4.   

    T:Tstringlist;
    begin
       T:=Tstringlist.create;
       try
         T.add( ....);
         finally
            freeandnil(T);
         end;
    end;
      

  5.   

    Frees an object reference and replaces the reference with nil..procedure FreeAndNil(var Obj);Use FreeAndNil to ensure that a variable is nil after you free the object it references. Pass any variable that represents an object as the Obj parameter.Warning: Do not pass a value for Obj if it is not an instance of TObject or one of its descendants.
      

  6.   

    《Delphi7入门与精通》(Mastering Delphi 7) 还说了,用FreeAndNil()
      

  7.   

    没办法
    因为对象被释放时
    对象变量这个指针并没有被清空
    而且对象所占的内存(非对象指针)并没有被清空
    这是Delphi或者操作系统管理内存的问题
    对象所占的内存在对象释放时并没有清空
    只是被标记为可以使用
    其中所包含的内容还在
    所以你无法通过其他的办法来判断一个对象是否被释放了。