Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: src/api.cc

Issue 1058253003: Adding V8 api to get memory statistics of spaces in V8::Heap. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added pimpl class for using vector. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/heap/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « include/v8.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698