- Fix link resolution with proper relative/absolute path handling - Improve link styling with underline decoration - Hide leaf nodes from tree, only show directories - Fix log file path for packaged app
796 B
796 B
RefCounted::Release
void Release();
减少引用计数。
描述
原子地减少引用计数。当引用计数归零时,对象会自动 delete this。这是实现自动内存管理的关键方法。
复杂度: O(1)(归零时为 O(n),n 为对象大小)
示例:
#include <XCEngine/Core/RefCounted.h>
class MyObject : public RefCounted {
public:
void DoSomething() { /* ... */ }
};
// 创建对象(构造时 refCount = 1)
MyObject* obj = new MyObject();
// 手动增加引用
obj->AddRef(); // refCount = 2
// 释放引用
obj->Release(); // refCount = 1
obj->Release(); // refCount = 0, 对象被自动 delete
相关文档
- RefCounted 总览 - 返回类总览
- AddRef - 增加引用计数