diff --git a/src/gpgmm/common/DedicatedMemoryAllocator.cpp b/src/gpgmm/common/DedicatedMemoryAllocator.cpp index 73fdc5b0..dee7013b 100644 --- a/src/gpgmm/common/DedicatedMemoryAllocator.cpp +++ b/src/gpgmm/common/DedicatedMemoryAllocator.cpp @@ -46,9 +46,7 @@ namespace gpgmm { mStats.UsedBlockCount++; mStats.UsedBlockUsage += allocation->GetSize(); - allocation->SetOffset(0); allocation->SetAllocator(this); - allocation->SetBlock(new MemoryBlock{0, allocation->GetSize()}); return allocation; } @@ -60,11 +58,9 @@ namespace gpgmm { std::lock_guard lock(mMutex); - MemoryBlock* block = allocation->GetBlock(); mStats.UsedBlockCount--; - mStats.UsedBlockUsage -= block->Size; + mStats.UsedBlockUsage -= allocation->GetSize(); - SafeDelete(block); GetNextInChain()->DeallocateMemory(std::move(allocation)); } diff --git a/src/gpgmm/common/DedicatedMemoryAllocator.h b/src/gpgmm/common/DedicatedMemoryAllocator.h index f6a72bc9..cce94682 100644 --- a/src/gpgmm/common/DedicatedMemoryAllocator.h +++ b/src/gpgmm/common/DedicatedMemoryAllocator.h @@ -19,12 +19,13 @@ namespace gpgmm { - // DedicatedMemoryAllocator allocates from device memory with exactly one block. - // DedicatedMemoryAllocator is useful in situations where whole memory objects could be reused - // without the need for sub-allocation. DedicatedMemoryAllocator also allows - // memory to be tracked. + // DedicatedMemoryAllocator always allocates the entire region of memory. + // This is useful in situations where entire memory allocations could be reused + // without the need for sub-allocation. class DedicatedMemoryAllocator final : public MemoryAllocatorBase { public: + // Constructs a dedicated allocation. + // The underlying |memoryAllocator| cannot be a sub-allocator. DedicatedMemoryAllocator(ScopedRef memoryAllocator, uint64_t memoryAlignment); diff --git a/src/gpgmm/common/MemoryAllocation.h b/src/gpgmm/common/MemoryAllocation.h index bf5713e6..0efe97bd 100644 --- a/src/gpgmm/common/MemoryAllocation.h +++ b/src/gpgmm/common/MemoryAllocation.h @@ -99,6 +99,8 @@ namespace gpgmm { uint64_t mRequestSize; #endif + // Assigns a contiguously allocated sub-region. + // When the entire allocation region gets assigned, |mBlock| will be nullptr. MemoryBlock* mBlock; }; } // namespace gpgmm