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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 is_on = false; | 594 is_on = false; |
595 } | 595 } |
596 | 596 |
597 extern "C" void HeapProfilerDump(const char* reason) { | 597 extern "C" void HeapProfilerDump(const char* reason) { |
598 SpinLockHolder l(&heap_lock); | 598 SpinLockHolder l(&heap_lock); |
599 if (is_on && !dumping) { | 599 if (is_on && !dumping) { |
600 DumpProfileLocked(reason); | 600 DumpProfileLocked(reason); |
601 } | 601 } |
602 } | 602 } |
603 | 603 |
| 604 extern "C" void HeapProfilerMarkBaseline() { |
| 605 SpinLockHolder l(&heap_lock); |
| 606 |
| 607 if (!is_on) return; |
| 608 |
| 609 heap_profile->MarkCurrentAllocations(HeapProfileTable::MARK_ONE); |
| 610 } |
| 611 |
| 612 extern "C" void HeapProfilerMarkInteresting() { |
| 613 SpinLockHolder l(&heap_lock); |
| 614 |
| 615 if (!is_on) return; |
| 616 |
| 617 heap_profile->MarkUnmarkedAllocations(HeapProfileTable::MARK_TWO); |
| 618 } |
| 619 |
| 620 extern "C" void HeapProfilerDumpAliveObjects(const char* filename) { |
| 621 SpinLockHolder l(&heap_lock); |
| 622 |
| 623 if (!is_on) return; |
| 624 |
| 625 heap_profile->DumpMarkedObjects(HeapProfileTable::MARK_TWO, filename); |
| 626 } |
| 627 |
604 //---------------------------------------------------------------------- | 628 //---------------------------------------------------------------------- |
605 // Initialization/finalization code | 629 // Initialization/finalization code |
606 //---------------------------------------------------------------------- | 630 //---------------------------------------------------------------------- |
607 | 631 |
608 // Initialization code | 632 // Initialization code |
609 static void HeapProfilerInit() { | 633 static void HeapProfilerInit() { |
610 // Everything after this point is for setting up the profiler based on envvar | 634 // Everything after this point is for setting up the profiler based on envvar |
611 char fname[PATH_MAX]; | 635 char fname[PATH_MAX]; |
612 if (!GetUniquePathFromEnv("HEAPPROFILE", fname)) { | 636 if (!GetUniquePathFromEnv("HEAPPROFILE", fname)) { |
613 return; | 637 return; |
(...skipping 14 matching lines...) Expand all Loading... |
628 | 652 |
629 // class used for finalization -- dumps the heap-profile at program exit | 653 // class used for finalization -- dumps the heap-profile at program exit |
630 struct HeapProfileEndWriter { | 654 struct HeapProfileEndWriter { |
631 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } | 655 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } |
632 }; | 656 }; |
633 | 657 |
634 // We want to make sure tcmalloc is up and running before starting the profiler | 658 // We want to make sure tcmalloc is up and running before starting the profiler |
635 static const TCMallocGuard tcmalloc_initializer; | 659 static const TCMallocGuard tcmalloc_initializer; |
636 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); | 660 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); |
637 static HeapProfileEndWriter heap_profile_end_writer; | 661 static HeapProfileEndWriter heap_profile_end_writer; |
OLD | NEW |