| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 need_to_dump = true; | 352 need_to_dump = true; |
| 353 } else if (FLAGS_heap_profile_inuse_interval > 0 && | 353 } else if (FLAGS_heap_profile_inuse_interval > 0 && |
| 354 inuse_bytes > | 354 inuse_bytes > |
| 355 high_water_mark + FLAGS_heap_profile_inuse_interval) { | 355 high_water_mark + FLAGS_heap_profile_inuse_interval) { |
| 356 snprintf(buf, sizeof(buf), "%" PRId64 " MB currently in use", | 356 snprintf(buf, sizeof(buf), "%" PRId64 " MB currently in use", |
| 357 inuse_bytes >> 20); | 357 inuse_bytes >> 20); |
| 358 need_to_dump = true; | 358 need_to_dump = true; |
| 359 } else if (FLAGS_heap_profile_time_interval > 0 && | 359 } else if (FLAGS_heap_profile_time_interval > 0 && |
| 360 current_time - last_dump_time >= | 360 current_time - last_dump_time >= |
| 361 FLAGS_heap_profile_time_interval) { | 361 FLAGS_heap_profile_time_interval) { |
| 362 snprintf(buf, sizeof(buf), "%d sec since the last dump", | 362 snprintf(buf, sizeof(buf), "%" PRId64 " sec since the last dump", |
| 363 current_time - last_dump_time); | 363 current_time - last_dump_time); |
| 364 need_to_dump = true; | 364 need_to_dump = true; |
| 365 last_dump_time = current_time; | 365 last_dump_time = current_time; |
| 366 } | 366 } |
| 367 if (need_to_dump) { | 367 if (need_to_dump) { |
| 368 DumpProfileLocked(buf); | 368 DumpProfileLocked(buf); |
| 369 | 369 |
| 370 last_dump_alloc = total.alloc_size; | 370 last_dump_alloc = total.alloc_size; |
| 371 last_dump_free = total.free_size; | 371 last_dump_free = total.free_size; |
| 372 if (inuse_bytes > high_water_mark) | 372 if (inuse_bytes > high_water_mark) |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 | 686 |
| 687 // class used for finalization -- dumps the heap-profile at program exit | 687 // class used for finalization -- dumps the heap-profile at program exit |
| 688 struct HeapProfileEndWriter { | 688 struct HeapProfileEndWriter { |
| 689 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } | 689 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } |
| 690 }; | 690 }; |
| 691 | 691 |
| 692 // We want to make sure tcmalloc is up and running before starting the profiler | 692 // We want to make sure tcmalloc is up and running before starting the profiler |
| 693 static const TCMallocGuard tcmalloc_initializer; | 693 static const TCMallocGuard tcmalloc_initializer; |
| 694 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); | 694 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); |
| 695 static HeapProfileEndWriter heap_profile_end_writer; | 695 static HeapProfileEndWriter heap_profile_end_writer; |
| OLD | NEW |