Index: runtime/vm/zone.cc |
diff --git a/runtime/vm/zone.cc b/runtime/vm/zone.cc |
index 36e962260dd30ed433c67ff89812392ece46ec04..6d48e9a233c89029610c34710bb32df9b8ee684c 100644 |
--- a/runtime/vm/zone.cc |
+++ b/runtime/vm/zone.cc |
@@ -43,7 +43,13 @@ class Zone::Segment { |
void Zone::Segment::DeleteSegmentList(Segment* head) { |
Segment* current = head; |
+ Thread* current_thread = Thread::Current(); |
while (current != NULL) { |
+ if (current_thread != NULL) { |
+ // TODO(bkonyi) Handle special case of segment deletion within native |
+ // isolate. |
+ Thread::Current()->DecrementThreadMemoryUsage(current->size()); |
+ } |
Segment* next = current->next(); |
#ifdef DEBUG |
// Zap the entire current segment (including the header). |
@@ -68,6 +74,11 @@ Zone::Segment* Zone::Segment::New(intptr_t size, Zone::Segment* next) { |
#endif |
result->next_ = next; |
result->size_ = size; |
+ if (Thread::Current() != NULL) { |
+ // TODO(bkonyi) Handle special case of segment creation within native |
+ // isolate. |
+ Thread::Current()->IncrementThreadMemoryUsage(size); |
+ } |
return result; |
} |