docs: rebuild Memory API content
This commit is contained in:
@@ -6,34 +6,57 @@
|
||||
|
||||
**头文件**: `XCEngine/Memory/MemoryManager.h`
|
||||
|
||||
**描述**: 定义 `XCEngine/Memory` 子目录中的 `MemoryManager` public API。
|
||||
**描述**: 初始化内部系统分配器,并提供常用分配器的工厂接口。
|
||||
|
||||
## 概述
|
||||
|
||||
`MemoryManager.h` 是 `XCEngine/Memory` 子目录 下的 public header,当前页面作为平行目录中的 canonical 总览,用于汇总该头文件暴露的主要声明。
|
||||
`MemoryManager` 当前是内存模块的全局入口,但它的职责比名字听起来更窄。它主要做三件事:
|
||||
|
||||
## 声明概览
|
||||
- 创建和保存一个内部 `SystemAllocator`
|
||||
- 提供若干分配器工厂方法
|
||||
- 预留追踪、泄漏报告和报表接口
|
||||
|
||||
| 声明 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| `MemoryManager` | `class` | 头文件中的公开声明。 |
|
||||
它还定义了两个便利宏:
|
||||
|
||||
## 公共方法
|
||||
- `XE_ALLOC(allocator, size, ...)`
|
||||
- `XE_FREE(allocator, ptr)`
|
||||
|
||||
| 方法 | 描述 |
|
||||
## 当前实现边界
|
||||
|
||||
- 只有在 [Initialize](Initialize.md) 之后,`GetSystemAllocator()` 才会返回有效系统分配器。
|
||||
- `CreateLinearAllocator()` 即使在未初始化时也能工作,因为 `LinearAllocator` 在父分配器为空时会走自身的直接分配路径。
|
||||
- `CreateProxyAllocator()` 在未初始化时会创建一个底层分配器为空的对象,后续实际分配将产生未定义行为,因此应在初始化后使用。
|
||||
- 使用系统分配器作为底层或父分配器创建出来的对象,应在 [Shutdown](Shutdown.md) 之前销毁,否则会留下悬空指针。
|
||||
- `SetTrackAllocations()` 当前只修改标志位,不驱动统计逻辑。
|
||||
- `DumpMemoryLeaks()` 和 `GenerateMemoryReport()` 当前只向 `stdout` 输出标题。
|
||||
|
||||
## 生命周期
|
||||
|
||||
- [Get](Get.md) 返回进程级单例。
|
||||
- [Initialize](Initialize.md) 创建内部系统分配器。
|
||||
- [Shutdown](Shutdown.md) 销毁内部系统分配器。
|
||||
|
||||
## 线程语义
|
||||
|
||||
- 当前管理器自身没有锁。
|
||||
- 建议在启动和受控退出阶段使用,不要在多个线程中并发初始化或关闭。
|
||||
|
||||
## 公开方法
|
||||
|
||||
| 方法 | 说明 |
|
||||
|------|------|
|
||||
| [Get](Get.md) | 获取相关状态或对象。 |
|
||||
| [Initialize](Initialize.md) | 初始化内部状态。 |
|
||||
| [Shutdown](Shutdown.md) | 关闭并清理内部状态。 |
|
||||
| [GetSystemAllocator](GetSystemAllocator.md) | 获取相关状态或对象。 |
|
||||
| [CreateLinearAllocator](CreateLinearAllocator.md) | 创建新对象或资源。 |
|
||||
| [CreatePoolAllocator](CreatePoolAllocator.md) | 创建新对象或资源。 |
|
||||
| [CreateProxyAllocator](CreateProxyAllocator.md) | 创建新对象或资源。 |
|
||||
| [SetTrackAllocations](SetTrackAllocations.md) | 设置相关状态或配置。 |
|
||||
| [DumpMemoryLeaks](DumpMemoryLeaks.md) | 公开方法,详见头文件声明。 |
|
||||
| [GenerateMemoryReport](GenerateMemoryReport.md) | 公开方法,详见头文件声明。 |
|
||||
| [Get](Get.md) | 获取全局 `MemoryManager` 实例。 |
|
||||
| [Initialize](Initialize.md) | 初始化内存管理器。 |
|
||||
| [Shutdown](Shutdown.md) | 关闭内存管理器。 |
|
||||
| [GetSystemAllocator](GetSystemAllocator.md) | 获取内部系统分配器。 |
|
||||
| [CreateLinearAllocator](CreateLinearAllocator.md) | 创建线性分配器。 |
|
||||
| [CreatePoolAllocator](CreatePoolAllocator.md) | 创建池分配器。 |
|
||||
| [CreateProxyAllocator](CreateProxyAllocator.md) | 创建代理分配器。 |
|
||||
| [SetTrackAllocations](SetTrackAllocations.md) | 设置是否跟踪分配;当前仅保存标志位。 |
|
||||
| [DumpMemoryLeaks](DumpMemoryLeaks.md) | 输出泄漏报告标题。 |
|
||||
| [GenerateMemoryReport](GenerateMemoryReport.md) | 输出内存报告标题。 |
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [当前目录](../Memory.md) - 返回 `Memory` 平行目录
|
||||
- [API 总索引](../../../main.md) - 返回顶层索引
|
||||
- [当前模块](../Memory.md)
|
||||
- [Allocator Selection And Current Limits](../../../_guides/Memory/Allocator-Selection-And-Current-Limits.md)
|
||||
|
||||
Reference in New Issue
Block a user