docs: update memory and threading API docs
This commit is contained in:
35
docs/api/memory/proxy-allocator/get-total-allocated.md
Normal file
35
docs/api/memory/proxy-allocator/get-total-allocated.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# ProxyAllocator::GetTotalAllocated
|
||||
|
||||
```cpp
|
||||
size_t GetTotalAllocated() const override;
|
||||
```
|
||||
|
||||
获取累计分配的字节数。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 累计分配的字节数
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
#include <XCEngine/Memory/ProxyAllocator.h>
|
||||
|
||||
IAllocator* sysAlloc = MemoryManager::Get().GetSystemAllocator();
|
||||
ProxyAllocator proxy(sysAlloc, "TrackedAlloc");
|
||||
|
||||
proxy.Allocate(100);
|
||||
proxy.Allocate(200);
|
||||
|
||||
size_t totalAllocated = proxy.GetTotalAllocated();
|
||||
printf("Total allocated: %zu bytes\n", totalAllocated);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ProxyAllocator 总览](proxy-allocator.md) - 返回类总览
|
||||
Reference in New Issue
Block a user