diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-12-02 15:43:48 -0800 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-12-02 17:21:44 -0800 |
commit | 49285c596bb48a52c42eac4005707e441ef916a7 (patch) | |
tree | 2e26792a861d33d9b820fbdd3aae3694d2cc786f /dex2oat | |
parent | b5af2641acf9d2e247baaa2ac7674f91b801878d (diff) | |
download | art-49285c596bb48a52c42eac4005707e441ef916a7.zip art-49285c596bb48a52c42eac4005707e441ef916a7.tar.gz art-49285c596bb48a52c42eac4005707e441ef916a7.tar.bz2 |
Print memory usage in dex2oat shutdown
Example on mako:
I/dex2oat (31071): dex2oat took 31.195s (threads: 2) arena alloc=1013KB java alloc=13MB native alloc=32MB free=1490KB
Bug: 18069309
Change-Id: I08eac00842be35d4e659bddc8513f2062be725c9
(cherry picked from commit 3029df6d212894647ba0e5c23443c40912c6ecc8)
Diffstat (limited to 'dex2oat')
-rw-r--r-- | dex2oat/dex2oat.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index cd78df1..d957d27 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -21,6 +21,7 @@ #include <fstream> #include <iostream> +#include <malloc.h> // For mallinfo #include <sstream> #include <string> #include <vector> @@ -450,10 +451,10 @@ class Dex2Oat FINAL { timings_(timings) {} ~Dex2Oat() { + LogCompletionTime(); // Needs to be before since it accesses the runtime. if (kIsDebugBuild || (RUNNING_ON_VALGRIND != 0)) { delete runtime_; // See field declaration for why this is manual. } - LogCompletionTime(); } // Parse the arguments from the command line. In case of an unrecognized option or impossible @@ -1604,9 +1605,21 @@ class Dex2Oat FINAL { return ReadImageClasses(image_classes_stream); } - void LogCompletionTime() const { + void LogCompletionTime() { + std::ostringstream mallinfostr; +#ifdef HAVE_MALLOC_H + struct mallinfo info = mallinfo(); + const size_t allocated_space = static_cast<size_t>(info.uordblks); + const size_t free_space = static_cast<size_t>(info.fordblks); + mallinfostr << " native alloc=" << PrettySize(allocated_space) << " free=" + << PrettySize(free_space); +#endif + const ArenaPool* arena_pool = driver_->GetArenaPool(); + gc::Heap* heap = Runtime::Current()->GetHeap(); LOG(INFO) << "dex2oat took " << PrettyDuration(NanoTime() - start_ns_) - << " (threads: " << thread_count_ << ")"; + << " (threads: " << thread_count_ << ")" + << " arena alloc=" << PrettySize(arena_pool->GetBytesAllocated()) + << " java alloc=" << PrettySize(heap->GetBytesAllocated()) << mallinfostr.str(); } std::unique_ptr<CompilerOptions> compiler_options_; |