aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory/qv4mm_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-01-20 11:36:16 +0100
committerLars Knoll <lars.knoll@qt.io>2017-01-25 08:30:39 +0000
commit8cdd25357d29b958686089efcaaa5460a9855beb (patch)
treee5cc2e3e88708e33d752accf378352686e3034cf /src/qml/memory/qv4mm_p.h
parenta325b21e1bd51263551829089e9f31e2156bc641 (diff)
New allocator for huge items
Use a new Chunk based allocator for very large items. Change-Id: Ie61a72efb6340cd9ef54e4fdd957d7ca36c8729f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/memory/qv4mm_p.h')
-rw-r--r--src/qml/memory/qv4mm_p.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h
index 52d95aca0c..84769f33ba 100644
--- a/src/qml/memory/qv4mm_p.h
+++ b/src/qml/memory/qv4mm_p.h
@@ -116,6 +116,32 @@ struct StackAllocator {
uint currentChunk = 0;
};
+struct HugeItemAllocator {
+ HugeItemAllocator(ChunkAllocator *chunkAllocator)
+ : chunkAllocator(chunkAllocator)
+ {}
+
+ HeapItem *allocate(size_t size);
+ void sweep();
+ void freeAll();
+
+ size_t usedMem() const {
+ size_t used = 0;
+ for (const auto &c : chunks)
+ used += c.size;
+ return used;
+ }
+
+ ChunkAllocator *chunkAllocator;
+ struct HugeChunk {
+ Chunk *chunk;
+ size_t size;
+ };
+
+ std::vector<HugeChunk> chunks;
+};
+
+
class Q_QML_EXPORT MemoryManager
{
Q_DISABLE_COPY(MemoryManager);
@@ -369,6 +395,7 @@ public:
QV4::ExecutionEngine *engine;
ChunkAllocator *chunkAllocator;
StackAllocator<Heap::CallContext> stackAllocator;
+ HugeItemAllocator hugeItemAllocator;
QScopedPointer<Data> m_d;
PersistentValueStorage *m_persistentValues;
PersistentValueStorage *m_weakValues;