在悉尼,在物体前设置[弱]会受到惩罚吗?
In sydney does setting [weak] in front of an object make a penalty?
在delphi悉尼,在对象(不是界面)前设置[weak]会受到惩罚吗?
例子:
TMyObject = class(Tobject)
Private
[weak] FOwner: TMyObject;
....
end;
我问是因为我知道内部 [weak] 引用存储在列表中,因此它有一些缺点(关于速度)。由于现在 Sydney ARC 已经消失,因此不再需要将 [weak] 放在对象前面(据我所知),但因为我想让我的代码与 Rio 兼容,所以我问我是否可以安全离开[弱]参考没有无用性能丢失的痛苦(在悉尼)
there is a teeny-weeny problem with the [weak] attribute. It denotes a
zeroing weak reference that will be zeroed (niled) when the object it
points to is no longer valid. In order to do that, the compiler has to
track such objects at runtime and that introduces some overhead. If
you are tracking many such references, that can introduce a
significant performance loss.
[weak]
对象引用 的属性仅在 ARC 编译器上实现。在经典的非 ARC 编译器上,[weak]
属性在对象引用上没有任何作用,也没有任何惩罚。
由于 10.4 Sydney 不再有 ARC 编译器,因此不再需要 [weak]
属性,但它可用于保持向后兼容性。它不会影响使用非 ARC 编译器编译的代码。
[weak]
对非 ARC 编译器没有影响可以通过 CPU 视图轻松检查。
var
Obj: TObject;
[weak] WObj: TObject;
begin
Obj := TObject.Create;
WObj := Obj;
Obj.Free;
end;
在 Android ARC 编译器 10.3 上将 Obj
分配给弱 WObj
将调用 _InstWeakCopy
过程来跟踪弱引用:
使用 10.4 Android 编译器编译时的相同代码不再调用 _InstWeakCopy
:
注意:此答案严格涵盖 [weak]
属性在对象引用上使用时的行为。用于接口引用 [weak]
与以前一样工作,因为它是在 10.1 Berlin 的非 ARC 编译器中引入的。
在delphi悉尼,在对象(不是界面)前设置[weak]会受到惩罚吗? 例子:
TMyObject = class(Tobject)
Private
[weak] FOwner: TMyObject;
....
end;
我问是因为我知道内部 [weak] 引用存储在列表中,因此它有一些缺点(关于速度)。由于现在 Sydney ARC 已经消失,因此不再需要将 [weak] 放在对象前面(据我所知),但因为我想让我的代码与 Rio 兼容,所以我问我是否可以安全离开[弱]参考没有无用性能丢失的痛苦(在悉尼)
there is a teeny-weeny problem with the [weak] attribute. It denotes a zeroing weak reference that will be zeroed (niled) when the object it points to is no longer valid. In order to do that, the compiler has to track such objects at runtime and that introduces some overhead. If you are tracking many such references, that can introduce a significant performance loss.
[weak]
对象引用 的属性仅在 ARC 编译器上实现。在经典的非 ARC 编译器上,[weak]
属性在对象引用上没有任何作用,也没有任何惩罚。
由于 10.4 Sydney 不再有 ARC 编译器,因此不再需要 [weak]
属性,但它可用于保持向后兼容性。它不会影响使用非 ARC 编译器编译的代码。
[weak]
对非 ARC 编译器没有影响可以通过 CPU 视图轻松检查。
var
Obj: TObject;
[weak] WObj: TObject;
begin
Obj := TObject.Create;
WObj := Obj;
Obj.Free;
end;
在 Android ARC 编译器 10.3 上将 Obj
分配给弱 WObj
将调用 _InstWeakCopy
过程来跟踪弱引用:
使用 10.4 Android 编译器编译时的相同代码不再调用 _InstWeakCopy
注意:此答案严格涵盖 [weak]
属性在对象引用上使用时的行为。用于接口引用 [weak]
与以前一样工作,因为它是在 10.1 Berlin 的非 ARC 编译器中引入的。