| 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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 } | 613 } |
| 614 | 614 |
| 615 extern "C" void HeapProfilerDumpAliveObjects(const char* filename) { | 615 extern "C" void HeapProfilerDumpAliveObjects(const char* filename) { |
| 616 SpinLockHolder l(&heap_lock); | 616 SpinLockHolder l(&heap_lock); |
| 617 | 617 |
| 618 if (!is_on) return; | 618 if (!is_on) return; |
| 619 | 619 |
| 620 heap_profile->DumpMarkedObjects(HeapProfileTable::MARK_TWO, filename); | 620 heap_profile->DumpMarkedObjects(HeapProfileTable::MARK_TWO, filename); |
| 621 } | 621 } |
| 622 | 622 |
| 623 #if defined(OS_ANDROID) |
| 624 extern "C" void HeapProfilerSetTimeInterval(int time_interval) { |
| 625 FLAGS_heap_profile_time_interval = static_cast<int64>(time_interval); |
| 626 } |
| 627 |
| 628 extern "C" void HeapProfilerSetMmapProfile(bool mmap_profile) { |
| 629 FLAGS_mmap_profile = mmap_profile; |
| 630 } |
| 631 |
| 632 extern "C" void HeapProfilerSetDeepHeapProfile(bool deep_heap_profile) { |
| 633 FLAGS_deep_heap_profile = deep_heap_profile; |
| 634 } |
| 635 #endif // defined(OS_ANDROID) |
| 636 |
| 623 //---------------------------------------------------------------------- | 637 //---------------------------------------------------------------------- |
| 624 // Initialization/finalization code | 638 // Initialization/finalization code |
| 625 //---------------------------------------------------------------------- | 639 //---------------------------------------------------------------------- |
| 626 | 640 |
| 627 // Initialization code | 641 // Initialization code |
| 628 static void HeapProfilerInit() { | 642 static void HeapProfilerInit() { |
| 629 // Everything after this point is for setting up the profiler based on envvar | 643 // Everything after this point is for setting up the profiler based on envvar |
| 630 char fname[PATH_MAX]; | 644 char fname[PATH_MAX]; |
| 631 if (!GetUniquePathFromEnv("HEAPPROFILE", fname)) { | 645 if (!GetUniquePathFromEnv("HEAPPROFILE", fname)) { |
| 632 return; | 646 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 647 | 661 |
| 648 // class used for finalization -- dumps the heap-profile at program exit | 662 // class used for finalization -- dumps the heap-profile at program exit |
| 649 struct HeapProfileEndWriter { | 663 struct HeapProfileEndWriter { |
| 650 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } | 664 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } |
| 651 }; | 665 }; |
| 652 | 666 |
| 653 // We want to make sure tcmalloc is up and running before starting the profiler | 667 // We want to make sure tcmalloc is up and running before starting the profiler |
| 654 static const TCMallocGuard tcmalloc_initializer; | 668 static const TCMallocGuard tcmalloc_initializer; |
| 655 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); | 669 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); |
| 656 static HeapProfileEndWriter heap_profile_end_writer; | 670 static HeapProfileEndWriter heap_profile_end_writer; |
| OLD | NEW |