diff options
author | Ulf Hermann <[email protected]> | 2023-01-26 14:16:35 +0100 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2023-01-27 19:16:39 +0100 |
commit | d34d035022f9c7b9957cfb2abe0ba90486416ae2 (patch) | |
tree | 5d40957441598e02217191612573b7957fe06a4c /src/qml/memory/qv4mm.cpp | |
parent | dae8d32f92eb1e963308c81f209359060155b595 (diff) |
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 <[email protected]>
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src/qml/memory/qv4mm.cpp')
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index a7892e9729..5c3be27014 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -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); |