docs: fix naming conventions across threading, math, memory, core, and debug modules
threading/: - Rename 19 camelCase method files to hyphenated names - task-system: createtaskgroup→create-task-group, etc. - tasksystemconfig: enabletaskprofiling→enable-task-profiling, etc. - thread: getcurrentid→get-current-id, etc. - task: addref→add-ref, getid→get-id, etc. math/: - Rename underscore operator files to hyphenated - vector3: operator_add→operator-add, etc. - matrix4: gettranslation→get-translation, etc. - vector4: tovector3→to-vector3, constructor_vector3→constructor-vector3 - sphere: sphere_constructor→sphere-constructor, etc. memory/: - Remove duplicate memorymanager/ folder (kept manager/ which was correct) core/: - filewriter: Consolidate ctor-default.md and ctor-file.md into constructor.md - Rename dtor.md→destructor.md debug/: - filelogsink: Rename construct.md→constructor.md, ~filelogsink.md→destructor.md All overview pages updated with new file references.
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
# MemoryManager::CreateLinearAllocator
|
||||
|
||||
```cpp
|
||||
std::unique_ptr<LinearAllocator> CreateLinearAllocator(size_t size);
|
||||
```
|
||||
|
||||
创建并返回一个新的 LinearAllocator 实例,使用系统分配器作为底层。返回的 `unique_ptr` 管理分配器生命周期。
|
||||
|
||||
**参数:**
|
||||
- `size` - 分配器缓冲区大小(字节)
|
||||
|
||||
**返回:** LinearAllocator 的 unique_ptr
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
auto linear = MemoryManager::Get().CreateLinearAllocator(1024 * 1024);
|
||||
void* ptr = linear->Allocate(256);
|
||||
void* marker = linear->GetMarker();
|
||||
linear->Allocate(128);
|
||||
linear->SetMarker(marker);
|
||||
linear->Clear();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MemoryManager 总览](memorymanager.md) - 返回类总览
|
||||
- [LinearAllocator](../linear-allocator/linear-allocator.md) - 线性分配器
|
||||
@@ -1,37 +0,0 @@
|
||||
# MemoryManager::CreatePoolAllocator
|
||||
|
||||
```cpp
|
||||
std::unique_ptr<PoolAllocator> CreatePoolAllocator(size_t blockSize, size_t count);
|
||||
```
|
||||
|
||||
创建并返回一个新的 PoolAllocator 实例,使用系统分配器作为底层。返回的 `unique_ptr` 管理分配器生命周期。
|
||||
|
||||
**参数:**
|
||||
- `blockSize` - 每个内存块的大小(字节)
|
||||
- `count` - 内存池中块的数量
|
||||
|
||||
**返回:** PoolAllocator 的 unique_ptr
|
||||
|
||||
**复杂度:** O(blockSize * count)(需要预分配所有块)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
struct Particle {
|
||||
float x, y, z;
|
||||
float life;
|
||||
};
|
||||
|
||||
auto pool = MemoryManager::Get().CreatePoolAllocator(sizeof(Particle), 1000);
|
||||
void* block = pool->Allocate();
|
||||
auto* p = new (block) Particle{1.0f, 2.0f, 3.0f, 5.0f};
|
||||
p->~Particle();
|
||||
pool->Free(block);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MemoryManager 总览](memorymanager.md) - 返回类总览
|
||||
- [PoolAllocator](../pool-allocator/pool-allocator.md) - 内存池分配器
|
||||
@@ -1,36 +0,0 @@
|
||||
# MemoryManager::CreateProxyAllocator
|
||||
|
||||
```cpp
|
||||
std::unique_ptr<ProxyAllocator> CreateProxyAllocator(const char* name);
|
||||
```
|
||||
|
||||
创建并返回一个新的 ProxyAllocator 实例,包装系统分配器并使用指定名称。返回的 `unique_ptr` 管理分配器生命周期。
|
||||
|
||||
**参数:**
|
||||
- `name` - 代理分配器的名称
|
||||
|
||||
**返回:** ProxyAllocator 的 unique_ptr
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
auto proxy = MemoryManager::Get().CreateProxyAllocator("FrameData");
|
||||
void* ptr = proxy->Allocate(1024);
|
||||
void* ptr2 = proxy->Allocate(512);
|
||||
|
||||
const auto& stats = proxy->GetStats();
|
||||
printf("Peak: %zu bytes, Count: %zu\n",
|
||||
stats.peakAllocated, stats.allocationCount);
|
||||
|
||||
proxy->Free(ptr);
|
||||
proxy->Free(ptr2);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MemoryManager 总览](memorymanager.md) - 返回类总览
|
||||
- [ProxyAllocator](../proxy-allocator/proxy-allocator.md) - 代理分配器
|
||||
@@ -1,31 +0,0 @@
|
||||
# MemoryManager::DumpMemoryLeaks
|
||||
|
||||
```cpp
|
||||
void DumpMemoryLeaks();
|
||||
```
|
||||
|
||||
输出当前未释放的内存分配信息。如果启用了内存跟踪,此方法会遍历所有记录并报告疑似泄漏的分配。应在程序退出前调用,以便发现资源泄漏。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(n)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
MemoryManager::Get().Initialize();
|
||||
|
||||
// ... 程序运行 ...
|
||||
|
||||
// 程序退出前检查泄漏
|
||||
MemoryManager::Get().DumpMemoryLeaks();
|
||||
MemoryManager::Get().Shutdown();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MemoryManager 总览](memorymanager.md) - 返回类总览
|
||||
@@ -1,37 +0,0 @@
|
||||
# MemoryManager::GenerateMemoryReport
|
||||
|
||||
```cpp
|
||||
void GenerateMemoryReport();
|
||||
```
|
||||
|
||||
生成并输出当前内存使用情况的详细报告。报告内容包括各分配器的统计信息、峰值使用量、分配次数等。应在启用内存跟踪后调用。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(n)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
MemoryManager::Get().Initialize();
|
||||
|
||||
auto proxy = MemoryManager::Get().CreateProxyAllocator("GameFrame");
|
||||
proxy->Allocate(1024 * 1024);
|
||||
proxy->Allocate(512 * 1024);
|
||||
|
||||
// 生成内存报告
|
||||
MemoryManager::Get().GenerateMemoryReport();
|
||||
|
||||
proxy->Free(proxy->Allocate(256 * 1024));
|
||||
MemoryManager::Get().GenerateMemoryReport();
|
||||
|
||||
MemoryManager::Get().Shutdown();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MemoryManager 总览](memorymanager.md) - 返回类总览
|
||||
@@ -1,39 +0,0 @@
|
||||
# MemoryManager::Get
|
||||
|
||||
```cpp
|
||||
static MemoryManager& Get();
|
||||
```
|
||||
|
||||
获取 MemoryManager 单例实例。如果尚未创建则内部构造。此方法是获取内存管理器实例的唯一途径。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** MemoryManager 单例引用
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
// 获取单例
|
||||
MemoryManager& manager = MemoryManager::Get();
|
||||
|
||||
// 初始化
|
||||
manager.Initialize();
|
||||
|
||||
// 访问系统分配器
|
||||
IAllocator* sysAlloc = manager.GetSystemAllocator();
|
||||
|
||||
// 关闭
|
||||
manager.Shutdown();
|
||||
|
||||
// 多次调用返回同一实例
|
||||
MemoryManager& manager2 = MemoryManager::Get();
|
||||
// manager == manager2 为 true
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MemoryManager 总览](memorymanager.md) - 返回类总览
|
||||
@@ -1,27 +0,0 @@
|
||||
# MemoryManager::GetSystemAllocator
|
||||
|
||||
```cpp
|
||||
IAllocator* GetSystemAllocator();
|
||||
```
|
||||
|
||||
获取系统默认分配器。该分配器使用标准 C 库的 `std::malloc` 和平台特定的对齐分配函数(如 Windows 的 `_aligned_malloc`)作为后端,适用于通用内存分配场景。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 系统分配器指针
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
IAllocator* sysAlloc = MemoryManager::Get().GetSystemAllocator();
|
||||
void* ptr = sysAlloc->Allocate(1024);
|
||||
sysAlloc->Free(ptr);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MemoryManager 总览](memorymanager.md) - 返回类总览
|
||||
@@ -1,33 +0,0 @@
|
||||
# MemoryManager::Initialize
|
||||
|
||||
```cpp
|
||||
void Initialize();
|
||||
```
|
||||
|
||||
初始化内存管理器。创建系统默认分配器,设置内存跟踪标志。应在程序启动早期调用,且仅可调用一次。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(n)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
int main() {
|
||||
// 程序启动时初始化
|
||||
MemoryManager::Get().Initialize();
|
||||
|
||||
// 使用内存系统...
|
||||
|
||||
MemoryManager::Get().Shutdown();
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MemoryManager 总览](memorymanager.md) - 返回类总览
|
||||
@@ -1,85 +0,0 @@
|
||||
# MemoryManager
|
||||
|
||||
**命名空间**: `XCEngine::Memory`
|
||||
|
||||
**类型**: `class` (singleton)
|
||||
|
||||
**描述**: 全局内存管理器单例,提供系统分配器和各种专用分配器的创建与管理。
|
||||
|
||||
## 概述
|
||||
|
||||
`MemoryManager` 是 XCEngine 内存管理系统的核心单例。它负责维护系统分配器,提供分配器工厂方法,并支持内存泄漏检测和报告。
|
||||
|
||||
## 单例访问
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [`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) | 生成内存使用报告 |
|
||||
|
||||
## 宏定义
|
||||
|
||||
### XE_ALLOC
|
||||
|
||||
```cpp
|
||||
#define XE_ALLOC(allocator, size, ...) allocator->Allocate(size, ##__VA_ARGS__)
|
||||
```
|
||||
|
||||
内存分配宏。
|
||||
|
||||
### XE_FREE
|
||||
|
||||
```cpp
|
||||
#define XE_FREE(allocator, ptr) allocator->Free(ptr)
|
||||
```
|
||||
|
||||
内存释放宏。
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
// 初始化
|
||||
MemoryManager::Get().Initialize();
|
||||
|
||||
// 获取系统分配器
|
||||
IAllocator* sysAlloc = MemoryManager::Get().GetSystemAllocator();
|
||||
|
||||
// 创建专用分配器
|
||||
auto linearAlloc = MemoryManager::Get().CreateLinearAllocator(1024 * 1024);
|
||||
auto poolAlloc = MemoryManager::Get().CreatePoolAllocator(sizeof(MyObject), 1000);
|
||||
auto proxyAlloc = MemoryManager::Get().CreateProxyAllocator("GameFrame");
|
||||
|
||||
// 使用宏分配
|
||||
void* ptr = XE_ALLOC(proxyAlloc, 256);
|
||||
XE_FREE(proxyAlloc, ptr);
|
||||
|
||||
// 跟踪内存
|
||||
MemoryManager::Get().SetTrackAllocations(true);
|
||||
MemoryManager::Get().GenerateMemoryReport();
|
||||
|
||||
// 关闭
|
||||
MemoryManager::Get().Shutdown();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Memory 模块总览](../memory.md) - 返回模块总览
|
||||
- [IAllocator](../allocator/allocator.md) - 分配器接口
|
||||
- [LinearAllocator](../linear-allocator/linear-allocator.md) - 线性分配器
|
||||
- [PoolAllocator](../pool-allocator/pool-allocator.md) - 内存池分配器
|
||||
- [ProxyAllocator](../proxy-allocator/proxy-allocator.md) - 代理分配器
|
||||
@@ -1,35 +0,0 @@
|
||||
# MemoryManager::SetTrackAllocations
|
||||
|
||||
```cpp
|
||||
void SetTrackAllocations(bool track);
|
||||
```
|
||||
|
||||
设置是否启用内存分配跟踪。启用后系统会记录所有分配操作,用于生成内存报告和泄漏检测。
|
||||
|
||||
**参数:**
|
||||
- `track` - true 启用跟踪,false 禁用跟踪
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
MemoryManager::Get().Initialize();
|
||||
|
||||
// 禁用跟踪(提升性能)
|
||||
MemoryManager::Get().SetTrackAllocations(false);
|
||||
|
||||
// ... 大量内存操作 ...
|
||||
|
||||
// 重新启用跟踪进行分析
|
||||
MemoryManager::Get().SetTrackAllocations(true);
|
||||
MemoryManager::Get().GenerateMemoryReport();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MemoryManager 总览](memorymanager.md) - 返回类总览
|
||||
@@ -1,35 +0,0 @@
|
||||
# MemoryManager::Shutdown
|
||||
|
||||
```cpp
|
||||
void Shutdown();
|
||||
```
|
||||
|
||||
关闭内存管理器。执行内存泄漏检测报告,释放系统分配器。应在程序退出前调用。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(n)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
int main() {
|
||||
MemoryManager::Get().Initialize();
|
||||
|
||||
// ... 游戏主循环 ...
|
||||
|
||||
// 程序退出前关闭
|
||||
MemoryManager::Get().DumpMemoryLeaks();
|
||||
MemoryManager::Get().Shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MemoryManager 总览](memorymanager.md) - 返回类总览
|
||||
Reference in New Issue
Block a user