diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index eebcc140a429..02480caedb41 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -4262,9 +4262,10 @@ WorkerPrivate::GarbageCollectInternal(JSContext* aCx, bool aShrinking, { AssertIsOnWorkerThread(); - if (aCollectChildren) { + if (aShrinking || aCollectChildren) { JSRuntime* rt = JS_GetRuntime(aCx); JS::PrepareForFullGC(rt); + if (aShrinking) { JS::ShrinkingGC(rt, JS::gcreason::DOM_WORKER); } @@ -4273,10 +4274,6 @@ WorkerPrivate::GarbageCollectInternal(JSContext* aCx, bool aShrinking, } } else { - // If aCollectChildren is false then it means this collection request was - // not generated by the main thread. At the moment only the periodic GC - // timer can end up here, so rather than force a collection let the JS - // engine decide if we need one. JS_MaybeGC(aCx); } diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 06fe91c92814..b83b6be3234d 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -206,6 +206,7 @@ JSRuntime::setGCMaxMallocBytes(size_t value) * mean that value. */ gcMaxMallocBytes = (ptrdiff_t(value) >= 0) ? value : size_t(-1) >> 1; + resetGCMallocBytes(); for (ZonesIter zone(this); !zone.done(); zone.next()) zone->setGCMaxMallocBytes(value); }