aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-02-16 10:52:48 +0100
committerLars Knoll <lars.knoll@qt.io>2017-03-09 08:59:42 +0000
commitcb25abf2a818e76744426ff82619f7351132269f (patch)
tree31fafa6a538e532881f73e963891c153c4761b9c /src/qml/memory
parent78589bba88bcb3bce5a5996c762b324680d097a5 (diff)
Don't grow GC memory after an incremental GC
If the last GC was incremental, it would not clean up all garbage. Thus we should not look at the used memory after such a GC to determine whether we need to allocate additional memory. Change-Id: I57c33eeec63c16310920bc3dae074f4dcbb73d27 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/memory')
-rw-r--r--src/qml/memory/qv4mm.cpp6
-rw-r--r--src/qml/memory/qv4mm_p.h1
2 files changed, 5 insertions, 2 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index 233b83fcc0..1a1d92aa0e 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -1010,8 +1010,7 @@ void MemoryManager::sweep(bool lastSweep)
bool MemoryManager::shouldRunGC() const
{
size_t total = blockAllocator.totalSlots();
- size_t usedSlots = blockAllocator.usedSlotsAfterLastSweep;
- if (total > MinSlotsGCLimit && usedSlots * GCOverallocation < total * 100)
+ if (total > MinSlotsGCLimit && usedSlotsAfterLastFullSweep * GCOverallocation < total * 100)
return true;
return false;
}
@@ -1124,6 +1123,9 @@ void MemoryManager::runGC(bool forceFullCollection)
Q_ASSERT(blockAllocator.allocatedMem() == getUsedMem() + dumpBins(&blockAllocator, false));
}
+ if (!nextGCIsIncremental)
+ usedSlotsAfterLastFullSweep = blockAllocator.usedSlotsAfterLastSweep;
+
#if WRITEBARRIER(steele)
static int count = 0;
++count;
diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h
index 437e50cbe7..7f02a4f929 100644
--- a/src/qml/memory/qv4mm_p.h
+++ b/src/qml/memory/qv4mm_p.h
@@ -463,6 +463,7 @@ public:
std::size_t unmanagedHeapSize = 0; // the amount of bytes of heap that is not managed by the memory manager, but which is held onto by managed items.
std::size_t unmanagedHeapSizeGCLimit;
+ std::size_t usedSlotsAfterLastFullSweep = 0;
bool gcBlocked = false;
bool aggressiveGC = false;