Fix an obvious typo in the pool allocation sizing.
authorPetr Nejedly <pnejedly@blackberry.com>
Wed, 26 Jun 2013 21:36:54 +0000 (14:36 -0700)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sat, 29 Jun 2013 15:40:41 +0000 (17:40 +0200)
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 <simon.hausmann@digia.com>
src/qml/qml/v4/qv4mm.cpp

index 05c0db9..34f4728 100644 (file)
@@ -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);