Chromium Code Reviews| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 static LowLevelAlloc::Arena *heap_profiler_memory; | 142 static LowLevelAlloc::Arena *heap_profiler_memory; |
| 143 | 143 |
| 144 static void* ProfilerMalloc(size_t bytes) { | 144 static void* ProfilerMalloc(size_t bytes) { |
| 145 return LowLevelAlloc::AllocWithArena(bytes, heap_profiler_memory); | 145 return LowLevelAlloc::AllocWithArena(bytes, heap_profiler_memory); |
| 146 } | 146 } |
| 147 static void ProfilerFree(void* p) { | 147 static void ProfilerFree(void* p) { |
| 148 LowLevelAlloc::Free(p); | 148 LowLevelAlloc::Free(p); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // We use buffers of this size in DoGetHeapProfile. | 151 // We use buffers of this size in DoGetHeapProfile. |
| 152 static const int kProfileBufferSize = 1 << 20; | 152 // The size is 1 << 20 in the original google-perftools. Changed it to |
| 153 // 5 << 20 since larger buffers are requried for deeper profiling in Chromium. | |
|
jar (doing other things)
2011/12/22 16:02:09
Could you provide a comment that makes it clear wh
Dai Mikurube (NOT FULLTIME)
2011/12/26 03:58:26
Done.
| |
| 154 static const int kProfileBufferSize = 5 << 20; | |
| 153 | 155 |
| 154 // This is a last-ditch buffer we use in DumpProfileLocked in case we | 156 // This is a last-ditch buffer we use in DumpProfileLocked in case we |
| 155 // can't allocate more memory from ProfilerMalloc. We expect this | 157 // can't allocate more memory from ProfilerMalloc. We expect this |
| 156 // will be used by HeapProfileEndWriter when the application has to | 158 // will be used by HeapProfileEndWriter when the application has to |
| 157 // exit due to out-of-memory. This buffer is allocated in | 159 // exit due to out-of-memory. This buffer is allocated in |
| 158 // HeapProfilerStart. Access to this must be protected by heap_lock. | 160 // HeapProfilerStart. Access to this must be protected by heap_lock. |
| 159 static char* global_profiler_buffer = NULL; | 161 static char* global_profiler_buffer = NULL; |
| 160 | 162 |
| 161 | 163 |
| 162 //---------------------------------------------------------------------- | 164 //---------------------------------------------------------------------- |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 | 559 |
| 558 // class used for finalization -- dumps the heap-profile at program exit | 560 // class used for finalization -- dumps the heap-profile at program exit |
| 559 struct HeapProfileEndWriter { | 561 struct HeapProfileEndWriter { |
| 560 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } | 562 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } |
| 561 }; | 563 }; |
| 562 | 564 |
| 563 // We want to make sure tcmalloc is up and running before starting the profiler | 565 // We want to make sure tcmalloc is up and running before starting the profiler |
| 564 static const TCMallocGuard tcmalloc_initializer; | 566 static const TCMallocGuard tcmalloc_initializer; |
| 565 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); | 567 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); |
| 566 static HeapProfileEndWriter heap_profile_end_writer; | 568 static HeapProfileEndWriter heap_profile_end_writer; |
| OLD | NEW |