diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2024-03-18 14:28:33 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2024-03-19 13:47:24 +0100 |
commit | 0709d83dc65b49eadec7433bd9b3518b6473c6e8 (patch) | |
tree | 78ed542b54a8fa43ce211fb39013cfad87fa4696 /src | |
parent | fb0ee24b9f9268b4cb76be0860841f3f6ffaa988 (diff) |
QtQml: Provide an easy way to run non-incremental gc
We want the GC to run to completion on every invocation in that case.
We want the same behviour for the gc() method in QML for compatibility
reasons.
Task-number: QTBUG-119911
Change-Id: I50b50ec9d3cdf7d5193d906dd687fb9f0fd557f6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 8 | ||||
-rw-r--r-- | src/qml/memory/qv4mm_p.h | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlbuiltinfunctions.cpp | 5 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index a47a62de10..61dd59de23 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -1241,6 +1241,14 @@ bool MemoryManager::tryForceGCCompletion() return true; } +void MemoryManager::runFullGC() +{ + runGC(); + const bool incrementalGCStillRunning = m_markStack != nullptr; + if (incrementalGCStillRunning) + tryForceGCCompletion(); +} + void MemoryManager::runGC() { if (gcBlocked != Unblocked) { diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h index 3b623d22fa..ef0cd0c36c 100644 --- a/src/qml/memory/qv4mm_p.h +++ b/src/qml/memory/qv4mm_p.h @@ -314,6 +314,7 @@ public: void runGC(); bool tryForceGCCompletion(); + void runFullGC(); void dumpStats() const; @@ -376,7 +377,7 @@ private: bool didGCRun = false; if (aggressiveGC) { - runGC(); + runFullGC(); didGCRun = true; } diff --git a/src/qml/qml/qqmlbuiltinfunctions.cpp b/src/qml/qml/qqmlbuiltinfunctions.cpp index 8d237a832d..6eac9baf89 100644 --- a/src/qml/qml/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/qqmlbuiltinfunctions.cpp @@ -2370,10 +2370,7 @@ ReturnedValue GlobalExtensions::method_qsTrIdNoOp(const FunctionObject *, const ReturnedValue GlobalExtensions::method_gc(const FunctionObject *b, const Value *, const Value *, int) { auto mm = b->engine()->memoryManager; - auto oldLimit = mm->gcStateMachine->timeLimit; - mm->setGCTimeLimit(-1); // temporarily use non-incremental gc - mm->runGC(); - mm->gcStateMachine->timeLimit = oldLimit; + mm->runFullGC(); return QV4::Encode::undefined(); } |