Index: runtime/vm/scavenger.cc |
diff --git a/runtime/vm/scavenger.cc b/runtime/vm/scavenger.cc |
index e885b9801e7cf8c877ea03b8abc02333f726927f..83dd9ff66a683542a0dfef265a714df23045e2dd 100644 |
--- a/runtime/vm/scavenger.cc |
+++ b/runtime/vm/scavenger.cc |
@@ -415,13 +415,16 @@ Scavenger::Scavenger(Heap* heap, |
if (to_ == NULL) { |
FATAL("Out of memory.\n"); |
} |
- UpdateMaxHeapCapacity(); |
// Setup local fields. |
top_ = FirstObjectStart(); |
resolved_top_ = top_; |
end_ = to_->end(); |
survivor_end_ = FirstObjectStart(); |
+ |
+ UpdateMaxHeapCapacity(); |
+ UpdateMaxHeapUsage(); |
+ UpdateGlobalMaxUsed(); |
} |
@@ -501,6 +504,8 @@ void Scavenger::Epilogue(Isolate* isolate, |
} |
#endif // defined(DEBUG) |
from->Delete(); |
+ UpdateMaxHeapUsage(); |
+ UpdateGlobalMaxUsed(); |
if (invoke_api_callbacks && (isolate->gc_epilogue_callback() != NULL)) { |
(isolate->gc_epilogue_callback())(); |
} |
@@ -720,6 +725,36 @@ void Scavenger::UpdateMaxHeapCapacity() { |
} |
+void Scavenger::UpdateMaxHeapUsage() { |
+ if (heap_ == NULL) { |
+ // Some unit tests. |
+ return; |
+ } |
+ ASSERT(to_ != NULL); |
+ ASSERT(heap_ != NULL); |
+ Isolate* isolate = heap_->isolate(); |
+ ASSERT(isolate != NULL); |
+ isolate->GetHeapNewUsedMaxMetric()->SetValue(UsedInWords() * kWordSize); |
+} |
+ |
+ |
+void Scavenger::UpdateGlobalMaxUsed() { |
+ if (heap_ == NULL) { |
+ // Some unit tests. |
+ return; |
+ } |
+ ASSERT(to_ != NULL); |
+ ASSERT(heap_ != NULL); |
+ Isolate* isolate = heap_->isolate(); |
+ ASSERT(isolate != NULL); |
+ // This is technically under-counting, but, we cannot safely query the |
+ // page space here. This is also updated whenever a page space GC occurs, |
+ // which will reflect the (larger) combined heap usage. |
+ isolate->GetHeapGlobalUsedMaxMetric()->SetValue( |
+ (static_cast<int64_t>(heap_->UsedInWords(Heap::kNew)) * kWordSize)); |
+} |
+ |
+ |
uword Scavenger::ProcessWeakProperty(RawWeakProperty* raw_weak, |
ScavengerVisitor* visitor) { |
// The fate of the weak property is determined by its key. |