fix: improve doc link navigation and tree display
- 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
This commit is contained in:
72
docs/api/memory/allocator/allocator.md
Normal file
72
docs/api/memory/allocator/allocator.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# IAllocator
|
||||
|
||||
**命名空间**: `XCEngine::Memory`
|
||||
|
||||
**类型**: `class` (abstract interface)
|
||||
|
||||
**描述**: 内存分配器抽象接口,定义标准分配协议。
|
||||
|
||||
## 概述
|
||||
|
||||
`IAllocator` 是 XCEngine 内存管理系统的核心抽象接口。它定义了分配、释放和重新分配内存的标准方法,以及内存统计接口。所有专用分配器(LinearAllocator、PoolAllocator、ProxyAllocator)都实现此接口。
|
||||
|
||||
## 公共方法
|
||||
|
||||
### 内存操作
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `Allocate` | 分配内存 |
|
||||
| `Free` | 释放内存 |
|
||||
| `Reallocate` | 重新分配内存 |
|
||||
|
||||
### 统计信息
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `GetTotalAllocated` | 获取已分配总字节数 |
|
||||
| `GetTotalFreed` | 获取已释放总字节数 |
|
||||
| `GetPeakAllocated` | 获取峰值分配字节数 |
|
||||
| `GetAllocationCount` | 获取分配次数 |
|
||||
|
||||
### 元信息
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `GetName` | 获取分配器名称 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/Allocator.h>
|
||||
|
||||
class MyAllocator : public IAllocator {
|
||||
public:
|
||||
void* Allocate(size_t size, size_t alignment = 0) override {
|
||||
return ::operator new(size);
|
||||
}
|
||||
|
||||
void Free(void* ptr) override {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
void* Reallocate(void* ptr, size_t newSize) override {
|
||||
void* newPtr = Allocate(newSize);
|
||||
Free(ptr);
|
||||
return newPtr;
|
||||
}
|
||||
|
||||
size_t GetTotalAllocated() const override { return m_allocated; }
|
||||
size_t GetTotalFreed() const override { return m_freed; }
|
||||
size_t GetPeakAllocated() const override { return m_peak; }
|
||||
size_t GetAllocationCount() const override { return m_count; }
|
||||
const char* GetName() const override { return "MyAllocator"; }
|
||||
};
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Memory 模块总览](../memory.md) - 返回模块总览
|
||||
- [MemoryManager](../manager/manager.md) - 内存管理器
|
||||
- [LinearAllocator](../linear-allocator/linear-allocator.md) - 线性分配器
|
||||
- [PoolAllocator](../pool-allocator/pool-allocator.md) - 内存池分配器
|
||||
Reference in New Issue
Block a user