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); |
224 }; | 227 }; |
225 | 228 |
226 // Allocates "bytes" worth of memory and returns it. Increments | 229 // Allocates "bytes" worth of memory and returns it. Increments |
227 // metadata_system_bytes appropriately. May return NULL if allocation | 230 // metadata_system_bytes appropriately. May return NULL if allocation |
228 // fails. Requires pageheap_lock is held. | 231 // fails. Requires pageheap_lock is held. |
229 void* MetaDataAlloc(size_t bytes); | 232 void* MetaDataAlloc(size_t bytes); |
230 | 233 |
231 // Returns the total number of bytes allocated from the system. | 234 // Returns the total number of bytes allocated from the system. |
232 // Requires pageheap_lock is held. | 235 // Requires pageheap_lock is held. |
233 uint64_t metadata_system_bytes(); | 236 uint64_t metadata_system_bytes(); |
234 | 237 |
235 // size/depth are made the same size as a pointer so that some generic | 238 // size/depth are made the same size as a pointer so that some generic |
236 // code below can conveniently cast them back and forth to void*. | 239 // code below can conveniently cast them back and forth to void*. |
237 static const int kMaxStackDepth = 31; | 240 static const int kMaxStackDepth = 31; |
238 struct StackTrace { | 241 struct StackTrace { |
239 uintptr_t size; // Size of object | 242 uintptr_t size; // Size of object |
240 uintptr_t depth; // Number of PC values stored in array below | 243 uintptr_t depth; // Number of PC values stored in array below |
241 void* stack[kMaxStackDepth]; | 244 void* stack[kMaxStackDepth]; |
242 }; | 245 }; |
243 | 246 |
244 } // namespace tcmalloc | 247 } // namespace tcmalloc |
245 | 248 |
246 #endif // TCMALLOC_COMMON_H_ | 249 #endif // TCMALLOC_COMMON_H_ |
OLD | NEW |