-
Notifications
You must be signed in to change notification settings - Fork 159
Description
In several strategic places throughout Indy, the [weak]
attribute is used for various object references on ARC platforms. In some of these cases, the [unsafe]
attribute might make more sense to use, as letting the RTL automatically track and nil these references when the referenced objects are destroyed is not always necessary or desirable.
Maybe just replace all uses of [weak]
with [unsafe]
? On ARC platforms, [weak]
object referencing is not implemented very efficiently in Delphi (yet?), so there are performance overheads, and most places where [weak]
is being used by Indy, TComponent.Notification()
is also available, so [unsafe]
would be a better choice in those cases to avoid unwanted overhead.
Even Embarcadero agrees that replacing [weak]
with [unsafe]
where appropriate can be used is beneficial:
https://quality.embarcadero.com/browse/RSP-20087
Note: [unsafe]
is available for ARC platforms only in Delphi 10.1 Berlin and later. For earlier versions, perhaps use raw pointer references instead?
Update: Embarcadero is removing TObject
ARC memory management from all compilers in RAD Studio 10.4, so this will only be an issue for Delphi 10.1 Berlin, 10.2 Tokyo, and 10.3 Rio: