OLD | NEW |
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 | 215 |
216 // Number of objects to move between a per-thread list and a central | 216 // Number of objects to move between a per-thread list and a central |
217 // list in one shot. We want this to be not too small so we can | 217 // list in one shot. We want this to be not too small so we can |
218 // amortize the lock overhead for accessing the central list. Making | 218 // amortize the lock overhead for accessing the central list. Making |
219 // it too big may temporarily cause unnecessary memory wastage in the | 219 // it too big may temporarily cause unnecessary memory wastage in the |
220 // per-thread free list until the scavenger cleans up the list. | 220 // per-thread free list until the scavenger cleans up the list. |
221 inline int num_objects_to_move(size_t cl) { | 221 inline int num_objects_to_move(size_t cl) { |
222 return num_objects_to_move_[cl]; | 222 return num_objects_to_move_[cl]; |
223 } | 223 } |
224 | |
225 // Dump contents of the computed size map | |
226 void Dump(TCMalloc_Printer* out); | |
227 }; | 224 }; |
228 | 225 |
229 // Allocates "bytes" worth of memory and returns it. Increments | 226 // Allocates "bytes" worth of memory and returns it. Increments |
230 // metadata_system_bytes appropriately. May return NULL if allocation | 227 // metadata_system_bytes appropriately. May return NULL if allocation |
231 // fails. Requires pageheap_lock is held. | 228 // fails. Requires pageheap_lock is held. |
232 void* MetaDataAlloc(size_t bytes); | 229 void* MetaDataAlloc(size_t bytes); |
233 | 230 |
234 // Returns the total number of bytes allocated from the system. | 231 // Returns the total number of bytes allocated from the system. |
235 // Requires pageheap_lock is held. | 232 // Requires pageheap_lock is held. |
236 uint64_t metadata_system_bytes(); | 233 uint64_t metadata_system_bytes(); |
237 | 234 |
238 // size/depth are made the same size as a pointer so that some generic | 235 // size/depth are made the same size as a pointer so that some generic |
239 // code below can conveniently cast them back and forth to void*. | 236 // code below can conveniently cast them back and forth to void*. |
240 static const int kMaxStackDepth = 31; | 237 static const int kMaxStackDepth = 31; |
241 struct StackTrace { | 238 struct StackTrace { |
242 uintptr_t size; // Size of object | 239 uintptr_t size; // Size of object |
243 uintptr_t depth; // Number of PC values stored in array below | 240 uintptr_t depth; // Number of PC values stored in array below |
244 void* stack[kMaxStackDepth]; | 241 void* stack[kMaxStackDepth]; |
245 }; | 242 }; |
246 | 243 |
247 } // namespace tcmalloc | 244 } // namespace tcmalloc |
248 | 245 |
249 #endif // TCMALLOC_COMMON_H_ | 246 #endif // TCMALLOC_COMMON_H_ |
OLD | NEW |