MemoryManager: Retain the end of a chunk when allocating a new one
When we allocate a new chunk of memory, there may still be a bit of memory left at the end of the previous one. Throwing that away is a waste. Change-Id: I2b70b581cb835161b0819c3e11c2354010c6ca1c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
dae8d32f92
commit
d34d035022
|
@ -522,6 +522,14 @@ HeapItem *BlockAllocator::allocate(size_t size, bool forceAllocation) {
|
|||
if (!m) {
|
||||
if (!forceAllocation)
|
||||
return nullptr;
|
||||
if (nFree) {
|
||||
// Save any remaining slots of the current chunk
|
||||
// for later, smaller allocations.
|
||||
size_t bin = binForSlots(nFree);
|
||||
nextFree->freeData.next = freeBins[bin];
|
||||
nextFree->freeData.availableSlots = nFree;
|
||||
freeBins[bin] = nextFree;
|
||||
}
|
||||
Chunk *newChunk = chunkAllocator->allocate();
|
||||
Q_V4_PROFILE_ALLOC(engine, Chunk::DataSize, Profiling::HeapPage);
|
||||
chunks.push_back(newChunk);
|
||||
|
|
Loading…
Reference in New Issue