Bug 678422 - Avoid wasting half of nsPresArena's allocated memory due to clownshoes. r=roc.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 11 Aug 2011 18:53:29 -0700
changeset 74298 1f84f5eb5079bffc321c115f167db8402841de8e
parent 74297 febd4e26179c8780758a75c22e0fdbf30aa0f665
child 74299 77a0d9f09820956bce5c4e1818ed540762fd6c23
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersroc
bugs678422
milestone8.0a1
Bug 678422 - Avoid wasting half of nsPresArena's allocated memory due to clownshoes. r=roc.
layout/base/nsPresArena.cpp
--- a/layout/base/nsPresArena.cpp
+++ b/layout/base/nsPresArena.cpp
@@ -78,17 +78,21 @@
 #   define MAP_ANON MAP_ANONYMOUS
 #  else
 #   error "Don't know how to get anonymous memory"
 #  endif
 # endif
 #endif
 
 // Size to use for PLArena block allocations.
-static const size_t ARENA_PAGE_SIZE = 4096;
+// XXX: This should be 8192;  the subtracted elements are a hack that's
+// required to ensure the allocation requests are power-of-two-sized and thus
+// avoid lots of wasted memory caused by the heap allocator rounding up request
+// sizes.  Bug 676457 will fix it properly.
+static const size_t ARENA_PAGE_SIZE = 8192 - sizeof(PLArena) - PL_ARENA_CONST_ALIGN_MASK;
 
 // Freed memory is filled with a poison value, which we arrange to
 // form a pointer either to an always-unmapped region of the address
 // space, or to a page that has been reserved and rendered
 // inaccessible via OS primitives.  See tests/TestPoisonArea.cpp for
 // extensive discussion of the requirements for this page.  The code
 // from here to 'class FreeList' needs to be kept in sync with that
 // file.