Bug 894993 - 'SessionWorker takes lots of memory'. r=billm+khuey.
authorBen Turner <bent.mozilla@gmail.com>
Thu, 25 Jul 2013 15:03:27 -0400
changeset 140050 f1e8ada1ddf78a8eb72a4b3309e46efc92e5ff5d
parent 140049 cdf2423ff693dce317579e242bfc5119373821d6
child 140051 3b5b43a6b50ab24b92103a97c87a369348f960cc
push id25013
push userryanvm@gmail.com
push dateFri, 26 Jul 2013 14:47:14 +0000
treeherdermozilla-central@52f9e8ffe111 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs894993
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 894993 - 'SessionWorker takes lots of memory'. r=billm+khuey.
dom/workers/WorkerPrivate.cpp
js/src/vm/Runtime.cpp
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -4257,31 +4257,28 @@ WorkerPrivate::UpdateJITHardeningInterna
 }
 
 void
 WorkerPrivate::GarbageCollectInternal(JSContext* aCx, bool aShrinking,
                                       bool aCollectChildren)
 {
   AssertIsOnWorkerThread();
 
-  if (aCollectChildren) {
+  if (aShrinking || aCollectChildren) {
     JSRuntime* rt = JS_GetRuntime(aCx);
     JS::PrepareForFullGC(rt);
+
     if (aShrinking) {
       JS::ShrinkingGC(rt, JS::gcreason::DOM_WORKER);
     }
     else {
       JS::GCForReason(rt, JS::gcreason::DOM_WORKER);
     }
   }
   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);
   }
 
   if (aCollectChildren) {
     for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
       mChildWorkers[index]->GarbageCollect(aCx, aShrinking);
     }
   }
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -201,16 +201,17 @@ JSRuntime::getDefaultLocale()
 void
 JSRuntime::setGCMaxMallocBytes(size_t value)
 {
     /*
      * For compatibility treat any value that exceeds PTRDIFF_T_MAX to
      * 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);
 }
 
 void
 JSRuntime::updateMallocCounter(size_t nbytes)
 {
     updateMallocCounter(NULL, nbytes);