docs: update memory and threading API docs
This commit is contained in:
37
docs/api/memory/proxy-allocator/get-allocation-count.md
Normal file
37
docs/api/memory/proxy-allocator/get-allocation-count.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# ProxyAllocator::GetAllocationCount
|
||||
|
||||
```cpp
|
||||
size_t GetAllocationCount() 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);
|
||||
void* p = proxy.Allocate(300);
|
||||
proxy.Free(p);
|
||||
|
||||
size_t count = proxy.GetAllocationCount();
|
||||
printf("Current allocation count: %zu\n", count);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ProxyAllocator 总览](proxy-allocator.md) - 返回类总览
|
||||
Reference in New Issue
Block a user