diff options
Diffstat (limited to 'src/page_heap.h')
-rw-r--r-- | src/page_heap.h | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/page_heap.h b/src/page_heap.h index 18abed1..9376a66 100644 --- a/src/page_heap.h +++ b/src/page_heap.h @@ -1,4 +1,3 @@ -// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- // Copyright (c) 2008, Google Inc. // All rights reserved. // @@ -76,6 +75,8 @@ namespace tcmalloc { // ------------------------------------------------------------------------- // We use PageMap2<> for 32-bit and PageMap3<> for 64-bit machines. +// ...except... +// On Windows, we use TCMalloc_PageMap1_LazyCommit<> for 32-bit machines. // We also use a simple one-level cache for hot PageID-to-sizeclass mappings, // because sometimes the sizeclass is all the information we need. @@ -89,7 +90,13 @@ template <int BITS> class MapSelector { // A two-level map for 32-bit machines template <> class MapSelector<32> { public: +#ifdef WIN32 +// A flat map for 32-bit machines (with lazy commit of memory). + typedef TCMalloc_PageMap1_LazyCommit<32-kPageShift> Type; +#else + // A two-level map for 32-bit machines typedef TCMalloc_PageMap2<32-kPageShift> Type; +#endif typedef PackedCache<32-kPageShift, uint16_t> CacheType; }; @@ -143,7 +150,7 @@ class PERFTOOLS_DLL_DECL PageHeap { // Page heap statistics struct Stats { - Stats() : system_bytes(0), free_bytes(0), unmapped_bytes(0), committed_bytes(0) {} + Stats() : system_bytes(0), free_bytes(0), unmapped_bytes(0) {} uint64_t system_bytes; // Total bytes allocated from system uint64_t free_bytes; // Total bytes on normal freelists uint64_t unmapped_bytes; // Total bytes on returned freelists @@ -192,11 +199,6 @@ class PERFTOOLS_DLL_DECL PageHeap { } void CacheSizeClass(PageID p, size_t cl) const { pagemap_cache_.Put(p, cl); } - bool GetAggressiveDecommit(void) {return aggressive_decommit_;} - void SetAggressiveDecommit(bool aggressive_decommit) { - aggressive_decommit_ = aggressive_decommit; - } - private: // Allocates a big block of memory for the pagemap once we reach more than // 128MB @@ -214,11 +216,13 @@ class PERFTOOLS_DLL_DECL PageHeap { // Never delay scavenging for more than the following number of // deallocated pages. With 4K pages, this comes to 4GB of // deallocation. - static const int kMaxReleaseDelay = 1 << 20; + // Chrome: Changed to 64MB + static const int kMaxReleaseDelay = 1 << 14; // If there is nothing to release, wait for so many pages before // scavenging again. With 4K pages, this comes to 1GB of memory. - static const int kDefaultReleaseDelay = 1 << 18; + // Chrome: Changed to 16MB + static const int kDefaultReleaseDelay = 1 << 12; // Pick the appropriate map and cache types based on pointer size typedef MapSelector<kAddressBits>::Type PageMap; @@ -242,7 +246,6 @@ class PERFTOOLS_DLL_DECL PageHeap { // Statistics on system, free, and unmapped bytes Stats stats_; - Span* SearchFreeAndLargeLists(Length n); bool GrowHeap(Length n); @@ -275,7 +278,7 @@ class PERFTOOLS_DLL_DECL PageHeap { void CommitSpan(Span* span); // Decommit the span. - bool DecommitSpan(Span* span); + void DecommitSpan(Span* span); // Prepends span to appropriate free list, and adjusts stats. void PrependToFreeList(Span* span); @@ -288,23 +291,15 @@ class PERFTOOLS_DLL_DECL PageHeap { void IncrementalScavenge(Length n); // Release the last span on the normal portion of this list. - // Return the length of that span or zero if release failed. + // Return the length of that span. Length ReleaseLastNormalSpan(SpanList* slist); - // Checks if we are allowed to take more memory from the system. - // If limit is reached and allowRelease is true, tries to release - // some unused spans. - bool EnsureLimit(Length n, bool allowRelease = true); - - bool MayMergeSpans(Span *span, Span *other); // Number of pages to deallocate before doing more scavenging int64_t scavenge_counter_; // Index of last free list where we released memory to the OS. int release_index_; - - bool aggressive_decommit_; }; } // namespace tcmalloc |