Reviewers: Søren Gjesse,
Description:
Add reporting of JS heap size limit to GetHeapStatistics.
I found it useful to know inside the heap profiler to avoid
crashes due to heap overflow.
Please review this at http://codereview.chromium.org/6111007/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M include/v8.h
M src/api.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
883bfad9458ebc31c511ff3ba93568e2d1eab635..3a9827b24d3ba2e361c4ba326446fdd87ebee314
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2515,6 +2515,7 @@ class V8EXPORT HeapStatistics {
size_t total_heap_size() { return total_heap_size_; }
size_t total_heap_size_executable() { return
total_heap_size_executable_; }
size_t used_heap_size() { return used_heap_size_; }
+ size_t heap_size_limit() { return heap_size_limit_; }
private:
void set_total_heap_size(size_t size) { total_heap_size_ = size; }
@@ -2522,10 +2523,12 @@ class V8EXPORT HeapStatistics {
total_heap_size_executable_ = size;
}
void set_used_heap_size(size_t size) { used_heap_size_ = size; }
+ void set_heap_size_limit(size_t size) { heap_size_limit_ = size; }
size_t total_heap_size_;
size_t total_heap_size_executable_;
size_t used_heap_size_;
+ size_t heap_size_limit_;
friend class V8;
};
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
110468e2313ec75196b7c7604d6c2612ff09e922..36248437c789f569d53e4a1cd3b1cd5ea7ae5404
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3299,7 +3299,8 @@ bool v8::V8::Dispose() {
HeapStatistics::HeapStatistics(): total_heap_size_(0),
total_heap_size_executable_(0),
- used_heap_size_(0) { }
+ used_heap_size_(0),
+ heap_size_limit_(0) { }
void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) {
@@ -3307,6 +3308,7 @@ void v8::V8::GetHeapStatistics(HeapStatistics*
heap_statistics) {
heap_statistics->set_total_heap_size_executable(
i::Heap::CommittedMemoryExecutable());
heap_statistics->set_used_heap_size(i::Heap::SizeOfObjects());
+ heap_statistics->set_heap_size_limit(i::Heap::MaxReserved());
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev