CommonLibVR
Loading...
Searching...
No Matches
AbstractHeap.h
Go to the documentation of this file.
1#pragma once
2
3#include "RE/B/BSAtomic.h"
4#include "RE/I/IMemoryHeap.h"
5
6namespace RE
7{
8 class HeapBlock;
9 class HeapBlockFreeHead;
10
12 {
13 public:
14 inline static constexpr auto RTTI = RTTI_AbstractHeap;
15 inline static constexpr auto VTABLE = VTABLE_AbstractHeap;
16
17 virtual ~AbstractHeap(); // 00
18
19 // override (IMemoryHeap)
20 virtual void GetMemoryStats(MemoryStats* a_stats) override; // 02
21 virtual void* AllocateAlignImpl(std::size_t a_size, std::uint32_t a_alignment) override; // 04
22 virtual void* TryAllocateImpl(std::size_t a_size, std::uint32_t a_alignment) override; // 06
23 virtual const char* GetName() const override; // 07 - { return name; }
24 virtual bool PointerInHeap(const void* a_pointer) const override; // 0A
25 virtual void GetHeapStats(HeapStats* a_stats, bool a_fullBlockInfo) override; // 0C
26 virtual bool ShouldTrySmallBlockPools(std::size_t a_size, MEM_CONTEXT a_context) override; // 0D - { return true; }
27 virtual std::uint32_t GetPageSize() const override; // 0E - { return pageSize; }
28
29 // add
30 virtual void* DoHeapAllocation(std::size_t a_size, std::size_t a_initialSize) = 0; // 0F
31 virtual void DoHeapFree(void* a_ptr) = 0; // 10
32 virtual std::size_t CreateMorePages(void* a_memory, std::size_t a_currentSize, std::size_t a_requestedBytes); // 11 - { return 0; }
33 virtual std::size_t CleanExtraPages(void* a_memory, std::size_t a_currentSize, std::size_t a_freeBytes); // 12 - { return 0; }
34 virtual void DecommitPages(HeapBlock* a_block); // 13 - { return; }
35 virtual void CommitPages(HeapBlock*, std::size_t); // 14 - { return; }
36
37 // members
39 const char* name; // 030
40 std::size_t minFreeBlockSize; // 038
41 std::uint32_t pageSize; // 040
42 std::uint32_t pageSizeFlag; // 040
43 std::size_t memHeapSize; // 048
44 std::size_t initialSize; // 050
45 std::size_t currentSize; // 058
46 std::size_t wastedMemory; // 060
47 std::size_t memAllocated; // 068
48 std::size_t memAllocatedHigh; // 070
49 std::size_t blockMemAllocated; // 078
50 char* memHeap; // 080
51 std::int32_t numBlocks; // 088
52 std::uint32_t pad08C; // 08C
55 std::int32_t numFreeBlocks; // 0A0
56 bool allowDecommits; // 0A4
57 bool supportsSwapping; // 0A5
58 std::uint16_t pad0A0; // 0A6
61 private:
63 };
64 static_assert(sizeof(AbstractHeap) == 0x2A8);
65}
#define KEEP_FOR_RE()
Definition PCH.h:517
Definition AbstractHeap.h:12
bool supportsSwapping
Definition AbstractHeap.h:57
const char * name
Definition AbstractHeap.h:39
std::size_t blockMemAllocated
Definition AbstractHeap.h:49
std::size_t memAllocatedHigh
Definition AbstractHeap.h:48
std::size_t minFreeBlockSize
Definition AbstractHeap.h:40
virtual void * TryAllocateImpl(std::size_t a_size, std::uint32_t a_alignment) override
BSCriticalSection criticalSection
Definition AbstractHeap.h:38
std::uint32_t pad08C
Definition AbstractHeap.h:52
virtual bool PointerInHeap(const void *a_pointer) const override
std::uint32_t pageSizeFlag
Definition AbstractHeap.h:42
HeapBlock * blockHead
Definition AbstractHeap.h:53
static constexpr auto RTTI
Definition AbstractHeap.h:14
virtual std::uint32_t GetPageSize() const override
virtual void DecommitPages(HeapBlock *a_block)
virtual void DoHeapFree(void *a_ptr)=0
HeapBlock * blockTail
Definition AbstractHeap.h:54
virtual bool ShouldTrySmallBlockPools(std::size_t a_size, MEM_CONTEXT a_context) override
std::size_t initialSize
Definition AbstractHeap.h:44
std::int32_t numBlocks
Definition AbstractHeap.h:51
std::size_t memAllocated
Definition AbstractHeap.h:47
virtual std::size_t CleanExtraPages(void *a_memory, std::size_t a_currentSize, std::size_t a_freeBytes)
virtual ~AbstractHeap()
std::uint32_t pageSize
Definition AbstractHeap.h:41
virtual void GetHeapStats(HeapStats *a_stats, bool a_fullBlockInfo) override
std::int32_t numFreeBlocks
Definition AbstractHeap.h:55
virtual void GetMemoryStats(MemoryStats *a_stats) override
virtual void * DoHeapAllocation(std::size_t a_size, std::size_t a_initialSize)=0
std::size_t memHeapSize
Definition AbstractHeap.h:43
bool allowDecommits
Definition AbstractHeap.h:56
virtual void CommitPages(HeapBlock *, std::size_t)
std::size_t currentSize
Definition AbstractHeap.h:45
std::size_t wastedMemory
Definition AbstractHeap.h:46
virtual const char * GetName() const override
virtual void * AllocateAlignImpl(std::size_t a_size, std::uint32_t a_alignment) override
char * memHeap
Definition AbstractHeap.h:50
HeapBlock * smallFreeLists[32]
Definition AbstractHeap.h:59
static constexpr auto VTABLE
Definition AbstractHeap.h:15
HeapBlockFreeHead * largeFreeTrees[32]
Definition AbstractHeap.h:60
virtual std::size_t CreateMorePages(void *a_memory, std::size_t a_currentSize, std::size_t a_requestedBytes)
std::uint16_t pad0A0
Definition AbstractHeap.h:58
Definition BSAtomic.h:49
Definition HeapBlockFreeHead.h:8
Definition HeapBlock.h:6
Definition IMemoryHeap.h:31
Definition AbsorbEffect.h:6
constexpr REL::ID RTTI_AbstractHeap(static_cast< std::uint64_t >(690286))
constexpr std::array< REL::ID, 1 > VTABLE_AbstractHeap
Definition Offsets_VTABLE.h:7355
Definition IMemoryHeap.h:10
Definition IMemoryStoreBase.h:6