Bug 1377738 - Fix leak of nursery memory. r=jandem, a=jcristau
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 07 Jul 2017 13:55:57 +0100
changeset 411976 3cefc04b2b98d1aeb929df9526f4bca6d60e7c25
parent 411975 6075562b897b0ec87d7075da96cfec60cdf38bc2
child 411977 dc00e73c06e10974b8e88e8ed1a7b918e256e2d0
push id7514
push userryanvm@gmail.com
push dateMon, 17 Jul 2017 13:37:24 +0000
treeherdermozilla-beta@e26b1f5d635e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem, jcristau
bugs1377738
milestone55.0
Bug 1377738 - Fix leak of nursery memory. r=jandem, a=jcristau
js/src/gc/GCRuntime.h
js/src/jsgc.cpp
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -47,17 +47,22 @@ enum IncrementalProgress
 
 class ChunkPool
 {
     Chunk* head_;
     size_t count_;
 
   public:
     ChunkPool() : head_(nullptr), count_(0) {}
+    ~ChunkPool() {
+        // TODO: We should be able to assert that the chunk pool is empty but
+        // this causes XPCShell test failures on Windows 2012. See bug 1379232.
+    }
 
+    bool empty() const { return !head_; }
     size_t count() const { return count_; }
 
     Chunk* head() { MOZ_ASSERT(head_); return head_; }
     Chunk* pop();
     void push(Chunk* chunk);
     Chunk* remove(Chunk* chunk);
 
 #ifdef DEBUG
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1175,20 +1175,20 @@ GCRuntime::init(uint32_t maxbytes, uint3
         return false;
 
     return true;
 }
 
 void
 GCRuntime::finish()
 {
-    /* Wait for the nursery sweeping to end. */
-    for (ZoneGroupsIter group(rt); !group.done(); group.next()) {
-        if (group->nursery().isEnabled())
-            group->nursery().waitBackgroundFreeEnd();
+    /* Wait for nursery background free to end and disable it to release memory. */
+    if (nursery().isEnabled()) {
+        nursery().waitBackgroundFreeEnd();
+        nursery().disable();
     }
 
     /*
      * Wait until the background finalization and allocation stops and the
      * helper thread shuts down before we forcefully release any remaining GC
      * memory.
      */
     helperState.finish();