From: Petr Nejedly Date: Wed, 26 Jun 2013 21:36:54 +0000 (-0700) Subject: Fix an obvious typo in the pool allocation sizing. X-Git-Tag: upstream/5.2.1~669^2~93 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1f4211ddea00c051647bda9a7fcd841f946dea8;p=platform%2Fupstream%2Fqtdeclarative.git 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 --- 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);