Browse Source

[2831] added more comments about crash in boost on multiple calls to shrink.

JINMEI Tatuya 12 years ago
parent
commit
5ab82e0009
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/lib/util/memory_segment_mapped.cc

+ 6 - 2
src/lib/util/memory_segment_mapped.cc

@@ -224,8 +224,12 @@ MemorySegmentMapped::shrinkToFit() {
     }
 
     // It appears an assertion failure is triggered within Boost if the size
-    // is too small.  To work this around we'll make it no-op if the size is
-    // already reasonably small.
+    // is too small (happening if shrink_to_fit() is called twice without
+    // allocating any memory from the shrunk segment).  To work this around
+    // we'll make it no-op if the size is already reasonably small.
+    // Using INITIAL_SIZE is not 100% reliable as it's irrelevant to the
+    // internal constraint of the Boost implementation.  But, in practice,
+    // it should be sufficiently large and safe.
     if (getSize() < INITIAL_SIZE) {
         return;
     }