Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: third_party/tcmalloc/page_heap.h

Issue 251065: Tracks the amount of committed vs uncommitted memory in tcmalloc's page heap's freelists (Closed)
Patch Set: whitespace Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/tcmalloc/page_heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 inline Span* GetDescriptor(PageID p) const { 114 inline Span* GetDescriptor(PageID p) const {
115 return reinterpret_cast<Span*>(pagemap_.get(p)); 115 return reinterpret_cast<Span*>(pagemap_.get(p));
116 } 116 }
117 117
118 // Dump state to stderr 118 // Dump state to stderr
119 void Dump(TCMalloc_Printer* out); 119 void Dump(TCMalloc_Printer* out);
120 120
121 // Return number of bytes allocated from system 121 // Return number of bytes allocated from system
122 inline uint64_t SystemBytes() const { return system_bytes_; } 122 inline uint64_t SystemBytes() const { return system_bytes_; }
123 123
124 inline uint64_t CommittedBytes() const { return committed_bytes_; }
125
124 // Return number of free bytes in heap 126 // Return number of free bytes in heap
125 uint64_t FreeBytes() const { 127 uint64_t FreeBytes() const {
126 return (static_cast<uint64_t>(free_pages_) << kPageShift); 128 return (static_cast<uint64_t>(free_pages_) << kPageShift);
127 } 129 }
128 130
129 bool Check(); 131 bool Check();
130 // Like Check() but does some more comprehensive checking. 132 // Like Check() but does some more comprehensive checking.
131 bool CheckExpensive(); 133 bool CheckExpensive();
132 bool CheckList(Span* list, Length min_pages, Length max_pages, 134 bool CheckList(Span* list, Length min_pages, Length max_pages,
133 int freelist); // ON_NORMAL_FREELIST or ON_RETURNED_FREELIST 135 int freelist); // ON_NORMAL_FREELIST or ON_RETURNED_FREELIST
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 183
182 // Array mapping from span length to a doubly linked list of free spans 184 // Array mapping from span length to a doubly linked list of free spans
183 SpanList free_[kMaxPages]; 185 SpanList free_[kMaxPages];
184 186
185 // Number of pages kept in free lists 187 // Number of pages kept in free lists
186 uintptr_t free_pages_; 188 uintptr_t free_pages_;
187 189
188 // Bytes allocated from system 190 // Bytes allocated from system
189 uint64_t system_bytes_; 191 uint64_t system_bytes_;
190 192
193 // Bytes committed, always <= system_bytes_.
194 uint64_t committed_bytes_;
195
191 bool GrowHeap(Length n); 196 bool GrowHeap(Length n);
192 197
193 // REQUIRES: span->length >= n 198 // REQUIRES: span->length >= n
194 // REQUIRES: span->location != IN_USE 199 // REQUIRES: span->location != IN_USE
195 // Remove span from its free list, and move any leftover part of 200 // Remove span from its free list, and move any leftover part of
196 // span into appropriate free lists. Also update "span" to have 201 // span into appropriate free lists. Also update "span" to have
197 // length exactly "n" and mark it as non-free so it can be returned 202 // length exactly "n" and mark it as non-free so it can be returned
198 // to the client. After all that, decrease free_pages_ by n and 203 // to the client. After all that, decrease free_pages_ by n and
199 // return span. 204 // return span.
200 Span* Carve(Span* span, Length n); 205 Span* Carve(Span* span, Length n);
(...skipping 12 matching lines...) Expand all
213 // Commit the span. 218 // Commit the span.
214 void CommitSpan(Span* span); 219 void CommitSpan(Span* span);
215 220
216 // Decommit the span. 221 // Decommit the span.
217 void DecommitSpan(Span* span); 222 void DecommitSpan(Span* span);
218 223
219 // Incrementally release some memory to the system. 224 // Incrementally release some memory to the system.
220 // IncrementalScavenge(n) is called whenever n pages are freed. 225 // IncrementalScavenge(n) is called whenever n pages are freed.
221 void IncrementalScavenge(Length n); 226 void IncrementalScavenge(Length n);
222 227
228 // Releases all memory held in the given list's 'normal' freelist and adds
229 // it to the 'released' freelist.
230 void ReleaseFreeList(Span* list, Span* returned);
231
223 // Number of pages to deallocate before doing more scavenging 232 // Number of pages to deallocate before doing more scavenging
224 int64_t scavenge_counter_; 233 int64_t scavenge_counter_;
225 234
226 // Index of last free list we scavenged 235 // Index of last free list we scavenged
227 int scavenge_index_; 236 int scavenge_index_;
228 }; 237 };
229 238
230 } // namespace tcmalloc 239 } // namespace tcmalloc
231 240
232 #endif // TCMALLOC_PAGE_HEAP_H_ 241 #endif // TCMALLOC_PAGE_HEAP_H_
OLDNEW
« no previous file with comments | « no previous file | third_party/tcmalloc/page_heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698