| OLD | NEW |
| 1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 | 137 |
| 138 void MallocExtension::MarkThreadIdle() { | 138 void MallocExtension::MarkThreadIdle() { |
| 139 // Default implementation does nothing | 139 // Default implementation does nothing |
| 140 } | 140 } |
| 141 | 141 |
| 142 void MallocExtension::MarkThreadBusy() { | 142 void MallocExtension::MarkThreadBusy() { |
| 143 // Default implementation does nothing | 143 // Default implementation does nothing |
| 144 } | 144 } |
| 145 | 145 |
| 146 void MallocExtension::ReleaseToSystem(size_t num_bytes) { |
| 147 // Default implementation does nothing |
| 148 } |
| 149 |
| 146 void MallocExtension::ReleaseFreeMemory() { | 150 void MallocExtension::ReleaseFreeMemory() { |
| 147 // Default implementation does nothing | 151 ReleaseToSystem(static_cast<size_t>(-1)); // SIZE_T_MAX |
| 148 } | 152 } |
| 149 | 153 |
| 150 void MallocExtension::SetMemoryReleaseRate(double rate) { | 154 void MallocExtension::SetMemoryReleaseRate(double rate) { |
| 151 // Default implementation does nothing | 155 // Default implementation does nothing |
| 152 } | 156 } |
| 153 | 157 |
| 154 double MallocExtension::GetMemoryReleaseRate() { | 158 double MallocExtension::GetMemoryReleaseRate() { |
| 155 return -1.0; | 159 return -1.0; |
| 156 } | 160 } |
| 157 | 161 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // client wants to focus on the latest stack traces. | 297 // client wants to focus on the latest stack traces. |
| 294 PrintHeader(writer, "growth", entries); | 298 PrintHeader(writer, "growth", entries); |
| 295 for (void** entry = entries; Count(entry) != 0; entry += 3 + Depth(entry)) { | 299 for (void** entry = entries; Count(entry) != 0; entry += 3 + Depth(entry)) { |
| 296 PrintStackEntry(writer, entry); | 300 PrintStackEntry(writer, entry); |
| 297 } | 301 } |
| 298 delete[] entries; | 302 delete[] entries; |
| 299 | 303 |
| 300 DumpAddressMap(writer); | 304 DumpAddressMap(writer); |
| 301 } | 305 } |
| 302 | 306 |
| 307 void MallocExtension::Ranges(void* arg, RangeFunction func) { |
| 308 // No callbacks by default |
| 309 } |
| 310 |
| 303 // These are C shims that work on the current instance. | 311 // These are C shims that work on the current instance. |
| 304 | 312 |
| 305 #define C_SHIM(fn, retval, paramlist, arglist) \ | 313 #define C_SHIM(fn, retval, paramlist, arglist) \ |
| 306 extern "C" PERFTOOLS_DLL_DECL retval MallocExtension_##fn paramlist { \ | 314 extern "C" PERFTOOLS_DLL_DECL retval MallocExtension_##fn paramlist { \ |
| 307 return MallocExtension::instance()->fn arglist; \ | 315 return MallocExtension::instance()->fn arglist; \ |
| 308 } | 316 } |
| 309 | 317 |
| 310 C_SHIM(VerifyAllMemory, int, (void), ()); | 318 C_SHIM(VerifyAllMemory, int, (void), ()); |
| 311 C_SHIM(VerifyNewMemory, int, (void* p), (p)); | 319 C_SHIM(VerifyNewMemory, int, (void* p), (p)); |
| 312 C_SHIM(VerifyArrayNewMemory, int, (void* p), (p)); | 320 C_SHIM(VerifyArrayNewMemory, int, (void* p), (p)); |
| 313 C_SHIM(VerifyMallocMemory, int, (void* p), (p)); | 321 C_SHIM(VerifyMallocMemory, int, (void* p), (p)); |
| 314 C_SHIM(MallocMemoryStats, int, | 322 C_SHIM(MallocMemoryStats, int, |
| 315 (int* blocks, size_t* total, int histogram[kMallocHistogramSize]), | 323 (int* blocks, size_t* total, int histogram[kMallocHistogramSize]), |
| 316 (blocks, total, histogram)); | 324 (blocks, total, histogram)); |
| 317 | 325 |
| 318 C_SHIM(GetStats, void, | 326 C_SHIM(GetStats, void, |
| 319 (char* buffer, int buffer_length), (buffer, buffer_length)); | 327 (char* buffer, int buffer_length), (buffer, buffer_length)); |
| 320 C_SHIM(GetNumericProperty, int, | 328 C_SHIM(GetNumericProperty, int, |
| 321 (const char* property, size_t* value), (property, value)); | 329 (const char* property, size_t* value), (property, value)); |
| 322 C_SHIM(SetNumericProperty, int, | 330 C_SHIM(SetNumericProperty, int, |
| 323 (const char* property, size_t value), (property, value)); | 331 (const char* property, size_t value), (property, value)); |
| 324 | 332 |
| 325 C_SHIM(MarkThreadIdle, void, (void), ()); | 333 C_SHIM(MarkThreadIdle, void, (void), ()); |
| 326 C_SHIM(MarkThreadBusy, void, (void), ()); | 334 C_SHIM(MarkThreadBusy, void, (void), ()); |
| 327 C_SHIM(ReleaseFreeMemory, void, (void), ()); | 335 C_SHIM(ReleaseFreeMemory, void, (void), ()); |
| 336 C_SHIM(ReleaseToSystem, void, (size_t num_bytes), (num_bytes)); |
| 328 C_SHIM(GetEstimatedAllocatedSize, size_t, (size_t size), (size)); | 337 C_SHIM(GetEstimatedAllocatedSize, size_t, (size_t size), (size)); |
| 329 C_SHIM(GetAllocatedSize, size_t, (void* p), (p)); | 338 C_SHIM(GetAllocatedSize, size_t, (void* p), (p)); |
| OLD | NEW |