Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index 9d4356c5140777598b0c67ebc3d293fc3bcacc37..aa37be26edb75762ba6319ed1ac69d61a61c37a8 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -5455,11 +5455,33 @@ bool v8::V8::Dispose() { |
| } |
| +class HeapSpacesStatistics { |
| + public: |
| + std::vector<HeapStatistics::SpaceStatistics>* SpacesStatistics() { |
| + return &spaces_statistics_; |
| + } |
| + |
| + private: |
| + std::vector<HeapStatistics::SpaceStatistics> spaces_statistics_; |
| +}; |
| + |
| + |
| HeapStatistics::HeapStatistics(): total_heap_size_(0), |
| total_heap_size_executable_(0), |
| total_physical_size_(0), |
| used_heap_size_(0), |
| - heap_size_limit_(0) { } |
| + heap_size_limit_(0) { |
| + spaces_statistics_ = new HeapSpacesStatistics(); |
| +} |
| + |
| + |
| +HeapStatistics::~HeapStatistics() { free(spaces_statistics_); } |
|
rmcilroy
2015/04/14 17:25:53
You are using 'new' and 'free' which is wrong - yo
|
| + |
| + |
| +std::vector<HeapStatistics::SpaceStatistics>* |
| +HeapStatistics::SpacesStatistics() { |
| + return spaces_statistics_->SpacesStatistics(); |
| +} |
| bool v8::V8::InitializeICU(const char* icu_data_file) { |
| @@ -6996,6 +7018,32 @@ void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { |
| heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); |
| heap_statistics->used_heap_size_ = heap->SizeOfObjects(); |
| heap_statistics->heap_size_limit_ = heap->MaxReserved(); |
| + |
| + HeapStatistics::SpaceStatistics new_space_stats( |
| + heap->GetSpaceName(i::NEW_SPACE), |
| + heap->new_space()->CommittedMemory(), |
| + heap->new_space()->Size(), |
| + heap->new_space()->Available(), |
| + heap->new_space()->CommittedPhysicalMemory()); |
| + heap_statistics->SpacesStatistics()->push_back(new_space_stats); |
| + |
| + for (int space = i::FIRST_PAGED_SPACE; space < i::LAST_PAGED_SPACE; space++) { |
| + HeapStatistics::SpaceStatistics space_stats( |
| + heap->GetSpaceName(space), |
| + heap->paged_space(space)->CommittedMemory(), |
| + heap->paged_space(space)->SizeOfObjects(), |
| + heap->paged_space(space)->Available(), |
| + heap->paged_space(space)->CommittedPhysicalMemory()); |
| + heap_statistics->SpacesStatistics()->push_back(space_stats); |
| + } |
| + |
| + HeapStatistics::SpaceStatistics lo_space_stats( |
| + heap->GetSpaceName(i::LO_SPACE), |
| + heap->lo_space()->CommittedMemory(), |
| + heap->lo_space()->SizeOfObjects(), |
| + heap->lo_space()->Available(), |
| + heap->lo_space()->CommittedPhysicalMemory()); |
| + heap_statistics->SpacesStatistics()->push_back(lo_space_stats); |
| } |