diff options
author | Michael Brasser <michael.brasser@live.com> | 2014-02-20 10:43:09 -0600 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-13 16:39:34 +0100 |
commit | f3a917644253347bcb7041fd9fc3b1570184b5f4 (patch) | |
tree | cf7c3295d600a0788d27d09707e23daedb05faa5 /src/qml/jsruntime/qv4mm.cpp | |
parent | 11e9c49e5420bf749e4da48b1f14fa7dc9e4716f (diff) |
Allow maximum block size to be specified as an environment variable.
A smaller maximum block size helps limit RAM usage on constrained
systems, at the cost of more frequent garbage collection.
Change-Id: Iba07d9cc628e3178dfaad35664c631844540bc9d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4mm.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4mm.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp index 7bb41f1eec..30a8a47ec8 100644 --- a/src/qml/jsruntime/qv4mm.cpp +++ b/src/qml/jsruntime/qv4mm.cpp @@ -152,6 +152,7 @@ struct MemoryManager::Data uint allocCount[MaxItemSize/16]; int totalItems; int totalAlloc; + uint maxShift; struct Chunk { PageAllocation memory; int chunkSize; @@ -184,6 +185,7 @@ struct MemoryManager::Data , stackTop(0) , totalItems(0) , totalAlloc(0) + , maxShift(10) , largeItems(0) { memset(smallItems, 0, sizeof(smallItems)); @@ -193,6 +195,12 @@ struct MemoryManager::Data scribble = !qgetenv("QV4_MM_SCRIBBLE").isEmpty(); aggressiveGC = !qgetenv("QV4_MM_AGGRESSIVE_GC").isEmpty(); exactGC = qgetenv("QV4_MM_CONSERVATIVE_GC").isEmpty(); + + QByteArray overrideMaxShift = qgetenv("QV4_MM_MAXBLOCK_SHIFT"); + bool ok; + uint override = overrideMaxShift.toUInt(&ok); + if (ok && override <= 11 && override > 0) + maxShift = override; } ~Data() @@ -308,10 +316,10 @@ Managed *MemoryManager::alloc(std::size_t size) // no free item available, allocate a new chunk { - // allocate larger chunks at a time to avoid excessive GC, but cap at 64M chunks + // allocate larger chunks at a time to avoid excessive GC, but cap at maximum chunk size (32MB by default) uint shift = ++m_d->nChunks[pos]; - if (shift > 10) - shift = 10; + if (shift > m_d->maxShift) + shift = m_d->maxShift; std::size_t allocSize = CHUNK_SIZE*(size_t(1) << shift); allocSize = roundUpToMultipleOf(WTF::pageSize(), allocSize); Data::Chunk allocation; |