CommonLibSSE NG
hkMemoryAllocator.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/H/hkBaseTypes.h"
4 
5 namespace RE
6 {
8  {
9  public:
10  inline static constexpr auto RTTI = RTTI_hkMemoryAllocator;
11  inline static constexpr auto VTABLE = VTABLE_hkMemoryAllocator;
12 
13  using MemoryWalkCallback = void(void* a_start, std::size_t a_size, bool a_allocated, std::int32_t a_pool, void* a_param);
14 
15  enum class MemoryState
16  {
17  kOK,
19  };
20 
22  {
23  public:
24  static constexpr std::int64_t INFINITE_SIZE = -1;
25 
26  // members
27  std::int64_t allocated; // 00
28  std::int64_t inUse; // 08
29  std::int64_t peakInUse; // 10
30  std::int64_t available; // 18
31  std::int64_t totalAvailable; // 20
32  std::int64_t largestBlock; // 28
33  };
34  static_assert(sizeof(MemoryStatistics) == 0x30);
35 
37  {
38  public:
39  virtual ~ExtendedInterface(); // 00
40 
41  // add
42  virtual void GarbageCollect() = 0; // 01
43  virtual void IncrementalGarbageCollect(std::int32_t a_numBlocks) = 0; // 02
44  virtual hkResult SetMemorySoftLimit(std::size_t a_maxMemory) = 0; // 03
45  [[nodiscard]] virtual std::size_t GetMemorySoftLimit() const = 0; // 04
46  virtual bool CanAllocTotal(std::int32_t a_numBytes) = 0; // 05
47  virtual hkResult WalkMemory(MemoryWalkCallback* a_callback, void* a_param) = 0; // 06
48  };
49  static_assert(sizeof(ExtendedInterface) == 0x8);
50 
51  virtual ~hkMemoryAllocator(); // 00
52 
53  // add
54  virtual void* BlockAlloc(std::int32_t a_numBytes) = 0; // 01
55  virtual void BlockFree(void* a_ptr, std::int32_t a_numBytes) = 0; // 02
56  virtual void* BufAlloc(std::int32_t& a_reqNumBytesInOut); // 03
57  virtual void BufFree(void* a_ptr, std::int32_t a_numBytes); // 04
58  virtual void* BufRealloc(void* a_ptrOld, std::int32_t a_oldNumBytes, std::int32_t& a_reqNumBytesInOut); // 05
59  virtual void BlockAllocBatch(void** a_ptrsOut, std::int32_t a_numPtrs, std::int32_t a_blockSize); // 06
60  virtual void BlockFreeBatch(void** a_ptrsIn, std::int32_t a_numPtrs, std::int32_t a_blockSize); // 07
61  virtual void GetMemoryStatistics(MemoryStatistics& a_usage) = 0; // 08
62  virtual std::int32_t GetAllocatedSize(const void* a_obj, std::int32_t a_numBytes) = 0; // 09
63  virtual void ResetPeakMemoryStatistics(); // 0A - { return; }
64  };
65  static_assert(sizeof(hkMemoryAllocator) == 0x8);
66 }
Definition: hkMemoryAllocator.h:8
static constexpr auto RTTI
Definition: hkMemoryAllocator.h:10
virtual void * BufAlloc(std::int32_t &a_reqNumBytesInOut)
void(void *a_start, std::size_t a_size, bool a_allocated, std::int32_t a_pool, void *a_param) MemoryWalkCallback
Definition: hkMemoryAllocator.h:13
virtual void ResetPeakMemoryStatistics()
virtual ~hkMemoryAllocator()
virtual void BlockAllocBatch(void **a_ptrsOut, std::int32_t a_numPtrs, std::int32_t a_blockSize)
virtual void BlockFree(void *a_ptr, std::int32_t a_numBytes)=0
static constexpr auto VTABLE
Definition: hkMemoryAllocator.h:11
virtual void * BufRealloc(void *a_ptrOld, std::int32_t a_oldNumBytes, std::int32_t &a_reqNumBytesInOut)
virtual std::int32_t GetAllocatedSize(const void *a_obj, std::int32_t a_numBytes)=0
MemoryState
Definition: hkMemoryAllocator.h:16
virtual void GetMemoryStatistics(MemoryStatistics &a_usage)=0
virtual void * BlockAlloc(std::int32_t a_numBytes)=0
virtual void BlockFreeBatch(void **a_ptrsIn, std::int32_t a_numPtrs, std::int32_t a_blockSize)
virtual void BufFree(void *a_ptr, std::int32_t a_numBytes)
Definition: AbsorbEffect.h:6
hkResult
Definition: hkBaseTypes.h:9
constexpr REL::VariantID RTTI_hkMemoryAllocator(689584, 397439, 0x1f55fd0)
constexpr std::array< REL::VariantID, 1 > VTABLE_hkMemoryAllocator
Definition: Offsets_VTABLE.h:4738
Definition: hkMemoryAllocator.h:37
virtual hkResult SetMemorySoftLimit(std::size_t a_maxMemory)=0
virtual hkResult WalkMemory(MemoryWalkCallback *a_callback, void *a_param)=0
virtual std::size_t GetMemorySoftLimit() const =0
virtual void IncrementalGarbageCollect(std::int32_t a_numBlocks)=0
virtual bool CanAllocTotal(std::int32_t a_numBytes)=0
Definition: hkMemoryAllocator.h:22
std::int64_t largestBlock
Definition: hkMemoryAllocator.h:32
std::int64_t totalAvailable
Definition: hkMemoryAllocator.h:31
std::int64_t allocated
Definition: hkMemoryAllocator.h:27
std::int64_t available
Definition: hkMemoryAllocator.h:30
std::int64_t peakInUse
Definition: hkMemoryAllocator.h:29
std::int64_t inUse
Definition: hkMemoryAllocator.h:28
static constexpr std::int64_t INFINITE_SIZE
Definition: hkMemoryAllocator.h:24