Ref Counted

游戏引擎很少使用引用计数指针的原因

一般游戏引擎用裸指针很多,参考:

https://news.ycombinator.com/item?id=11761338

解释是用引用计数指针,每一次加减引用都会访问到具体计数所在的cache line,大部分是垃圾缓存,会降低很多性能。

基类Ref Counted

发现很多引擎都有一个基类的计数类,例如godot和unreal:

https://github.com/godotengine/godot/blob/master/core/object/ref_counted.hhttps://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/Core/Public/Templates/RefCounting.h

Last updated