TList, TObjectList — — resource release

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

TOjectList = Class (Tlist);

TOjectList inherits from Tlist, look from the name you can know it is designed specifically for the object list, so in the end he enriches those functions.?

The first is TObject as the object, it will be convenient to use, without pointer compulsory.

In view of the current state of the richness of Notify processing, such as if it is deleted will refer to the point be cleared;

 procedure TObjectList.Notify(Ptr: Pointer; Action: TListNotification);
      begin
        if (Action = lnDeleted) and OwnsObjects then
          TObject(Ptr).Free;
       inherited Notify(Ptr, Action);
      end;

In Tlist, a Clear (), will call SetCount, SetCapacity; or delete all.

procedure TList.Clear();
     begin
        SetCount(0);
        SetCapacity(0);
     end;

When the object is destroyed, will automatically call Clear () to remove all.

destructor TList.Destroy;
      begin
         Clear();
      end;

Summary: if there is a need to use the best from the object list, TOjectList Start to release resources inheritance, processing mechanism.

If from Tlist Inheritance also must realize Notify() ,Convenient resource release, reduce trouble.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Elliot at December 12, 2013 - 2:39 PM