From a1f4211ddea00c051647bda9a7fcd841f946dea8 Mon Sep 17 00:00:00 2001 From: Petr Nejedly Date: Wed, 26 Jun 2013 14:36:54 -0700 Subject: [PATCH] Fix an obvious typo in the pool allocation sizing. The pooled allocator in V4 preallocates the memory in a reasonably sized chunks to limit the OS overhead of the allocations. The chunks are supposed to be exponentially bigger, but the chunk sizes should not depend on the size of the original allocation request. Before the fix, the first allocation in every bucket basically preallocated 64k slots of given size instead of 64k bytes, thus even a trivial application ended up with 28MB of such heap. After the fix, the same application is happy with <400kB of this managed heap. Change-Id: I1deae95bb6f45b8c67afe71d3a560b787357b31b Reviewed-by: Simon Hausmann --- src/qml/qml/v4/qv4mm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/qml/v4/qv4mm.cpp b/src/qml/qml/v4/qv4mm.cpp index 05c0db9..34f4728 100644 --- a/src/qml/qml/v4/qv4mm.cpp +++ b/src/qml/qml/v4/qv4mm.cpp @@ -200,7 +200,7 @@ Managed *MemoryManager::alloc(std::size_t size) uint shift = ++m_d->nChunks[pos]; if (shift > 10) shift = 10; - std::size_t allocSize = CHUNK_SIZE*(1 << shift)*size; + std::size_t allocSize = CHUNK_SIZE*(1 << shift); allocSize = roundUpToMultipleOf(WTF::pageSize(), allocSize); Data::Chunk allocation; allocation.memory = PageAllocation::allocate(allocSize, OSAllocator::JSGCHeapPages); -- 2.7.4