Can someone please explain what the purpose of the HasWeakRef and a different array manager is in the System.Generics.Collections?

Can someone please explain what the purpose of the HasWeakRef and a different array manager is in the System.Generics.Collections?

If you look at the implementation of System.TypInfo.HasWeakRef it only returns True for tkMethod or a record/array that has a field of tkMethod.

In such cases the list classes do not use Move but explicitly loop through the array and assign each element. What is the difference for tkMethod there as I always thought this is just a record of two pointers as defined in System.TMethod.

Comments

  1. I must admit I haven't been paying attention to the newfangled stuff. Why can't it move weakrefs?

    ReplyDelete
  2. Just a wild guess (away from Delphi at the moment so I can't check it): Something to do with anonymous methods perhaps? Assigning an array element would increase refcount where a simple Move wouldn't?

    ReplyDelete
  3. Ondrej Kelle It should not increase refcount because you are just moving the elements to another slot in the array. The ref count was increased the time it was put into the array which was a simple assignment.

    ReplyDelete

Post a Comment