docs: update memory and threading API docs
This commit is contained in:
36
docs/api/memory/linear-allocator/get-total-allocated.md
Normal file
36
docs/api/memory/linear-allocator/get-total-allocated.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# LinearAllocator::GetTotalAllocated
|
||||
|
||||
```cpp
|
||||
size_t GetTotalAllocated() const override;
|
||||
```
|
||||
|
||||
返回自分配器创建以来的累计分配字节数。对于线性分配器,这等于当前已使用的字节数(`m_offset`)。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 累计已分配的字节数
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/LinearAllocator.h>
|
||||
|
||||
LinearAllocator allocator(1024);
|
||||
|
||||
size_t total1 = allocator.GetTotalAllocated(); // 0
|
||||
|
||||
allocator.Allocate(256);
|
||||
allocator.Allocate(128);
|
||||
|
||||
size_t total2 = allocator.GetTotalAllocated(); // 384
|
||||
|
||||
allocator.Clear();
|
||||
|
||||
size_t total3 = allocator.GetTotalAllocated(); // 0(Clear 后重置)
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [LinearAllocator 总览](linear-allocator.md) - 返回类总览
|
||||
Reference in New Issue
Block a user