docs: 重构 API 文档结构并修正源码准确性

- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
  - math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
  - containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
  - core: 修复 types 链接错误
  - debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
  - memory: 修复头文件路径, malloc vs operator new, 新增方法文档
  - resources: 修复 Shader/Texture 链接错误
  - threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
This commit is contained in:
2026-03-19 00:22:30 +08:00
parent d0e16962c8
commit dc850d7739
1012 changed files with 26673 additions and 9222 deletions

72
docs/api/memory/memory.md Normal file
View File

@@ -0,0 +1,72 @@
# Memory 模块概览
**命名空间**: `XCEngine::Memory`
**类型**: `module`
**描述**: XCEngine 的内存管理模块,提供多种内存分配器实现。
## 概述
Memory 模块提供了一套完整的内存管理解决方案,包括基础分配器接口和各种专用分配器实现。
## 模块内容
### 分配器接口
| 组件 | 文件 | 描述 |
|------|------|------|
| [IAllocator](allocator/allocator.md) | `Allocator.h` | 内存分配器抽象接口 |
### 分配器实现
| 组件 | 文件 | 描述 |
|------|------|------|
| [LinearAllocator](linear-allocator/linear-allocator.md) | `LinearAllocator.h` | 线性分配器,适合帧分配 |
| [PoolAllocator](pool-allocator/pool-allocator.md) | `PoolAllocator.h` | 内存池分配器,适合固定大小对象 |
| [ProxyAllocator](proxy-allocator/proxy-allocator.md) | `ProxyAllocator.h` | 代理分配器,用于统计和跟踪 |
### 管理器
| 组件 | 文件 | 描述 |
|------|------|------|
| [MemoryManager](manager/manager.md) | `MemoryManager.h` | 全局内存管理器 |
## 分配器类型对比
| 分配器 | 适用场景 | 特点 |
|--------|----------|------|
| `IAllocator` | 基类接口 | 定义标准分配协议 |
| `LinearAllocator` | 帧分配、临时对象 | 快速分配,只支持按顺序释放 |
| `PoolAllocator` | 同尺寸对象池 | 高效分配,消除碎片 |
| `ProxyAllocator` | 调试和统计 | 记录分配信息,跟踪内存使用 |
## 宏定义
| 宏 | 描述 |
|----|------|
| `XE_ALLOC(allocator, size, ...)` | 内存分配宏 |
| `XE_FREE(allocator, ptr)` | 内存释放宏 |
## 使用示例
```cpp
#include <XCEngine/Memory/MemoryManager.h>
// 获取系统分配器
IAllocator* sysAlloc = MemoryManager::Get().GetSystemAllocator();
// 创建线性分配器
auto linearAlloc = MemoryManager::Get().CreateLinearAllocator(1024 * 1024);
// 使用代理分配器跟踪统计
auto proxyAlloc = MemoryManager::Get().CreateProxyAllocator("FrameData");
// 分配内存
void* ptr = XE_ALLOC(linearAlloc, 1024);
XE_FREE(linearAlloc, ptr);
```
## 相关文档
- [Containers 模块](../containers/containers.md) - 使用分配器的容器