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 static const int kProfileBufferSize = 5 << 20; |
|
Alexander Potapenko
2011/12/20 13:19:38
There should be some comment that describes this c
Dai Mikurube (NOT FULLTIME)
2011/12/21 05:32:45
Done.
| |
| 153 | 153 |
| 154 // This is a last-ditch buffer we use in DumpProfileLocked in case we | 154 // This is a last-ditch buffer we use in DumpProfileLocked in case we |
| 155 // can't allocate more memory from ProfilerMalloc. We expect this | 155 // can't allocate more memory from ProfilerMalloc. We expect this |
| 156 // will be used by HeapProfileEndWriter when the application has to | 156 // will be used by HeapProfileEndWriter when the application has to |
| 157 // exit due to out-of-memory. This buffer is allocated in | 157 // exit due to out-of-memory. This buffer is allocated in |
| 158 // HeapProfilerStart. Access to this must be protected by heap_lock. | 158 // HeapProfilerStart. Access to this must be protected by heap_lock. |
| 159 static char* global_profiler_buffer = NULL; | 159 static char* global_profiler_buffer = NULL; |
| 160 | 160 |
| 161 | 161 |
| 162 //---------------------------------------------------------------------- | 162 //---------------------------------------------------------------------- |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 | 555 |
| 556 // class used for finalization -- dumps the heap-profile at program exit | 556 // class used for finalization -- dumps the heap-profile at program exit |
| 557 struct HeapProfileEndWriter { | 557 struct HeapProfileEndWriter { |
| 558 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } | 558 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } |
| 559 }; | 559 }; |
| 560 | 560 |
| 561 // We want to make sure tcmalloc is up and running before starting the profiler | 561 // We want to make sure tcmalloc is up and running before starting the profiler |
| 562 static const TCMallocGuard tcmalloc_initializer; | 562 static const TCMallocGuard tcmalloc_initializer; |
| 563 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); | 563 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); |
| 564 static HeapProfileEndWriter heap_profile_end_writer; | 564 static HeapProfileEndWriter heap_profile_end_writer; |
| OLD | NEW |