"do not print trace line after scavenger collection")
DEFINE_bool(print_cumulative_gc_stat, false,
"print cumulative GC statistics in name=value format on exit")
+DEFINE_bool(print_max_heap_committed, false,
+ "print statistics of the maximum memory committed for the heap "
+ "in name=value format on exit")
DEFINE_bool(trace_gc_verbose, false,
"print more details following each garbage collection")
DEFINE_bool(trace_fragmentation, false,
// ConfigureHeap (survived_since_last_expansion_, external_allocation_limit_)
// Will be 4 * reserved_semispace_size_ to ensure that young
// generation can be aligned to its size.
+ maximum_committed_(0),
survived_since_last_expansion_(0),
sweep_generation_(0),
always_allocate_scope_depth_(0),
}
+void Heap::UpdateMaximumCommitted() {
+ if (!HasBeenSetUp()) return;
+
+ intptr_t current_committed_memory = CommittedMemory();
+ if (current_committed_memory > maximum_committed_) {
+ maximum_committed_ = current_committed_memory;
+ }
+}
+
+
intptr_t Heap::Available() {
if (!HasBeenSetUp()) return 0;
#endif
}
+ UpdateMaximumCommitted();
+
#ifdef DEBUG
ASSERT(!AllowHeapAllocation::IsAllowed() && gc_state_ == NOT_IN_GC);
}
}
+ UpdateMaximumCommitted();
+
isolate_->counters()->alive_after_last_gc()->Set(
static_cast<int>(SizeOfObjects()));
property_cell_space()->CommittedMemory() / KB));
isolate_->counters()->heap_sample_code_space_committed()->AddSample(
static_cast<int>(code_space()->CommittedMemory() / KB));
+
+ isolate_->counters()->heap_sample_maximum_committed()->AddSample(
+ static_cast<int>(MaximumCommittedMemory() / KB));
}
#define UPDATE_COUNTERS_FOR_SPACE(space) \
}
#endif
+ UpdateMaximumCommitted();
+
if (FLAG_print_cumulative_gc_stat) {
PrintF("\n");
PrintF("gc_count=%d ", gc_count_);
PrintF("\n\n");
}
+ if (FLAG_print_max_heap_committed) {
+ PrintF("\n");
+ PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ",
+ MaximumCommittedMemory());
+ PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ",
+ new_space_.MaximumCommittedMemory());
+ PrintF("maximum_committed_by_old_pointer_space=%" V8_PTR_PREFIX "d ",
+ old_data_space_->MaximumCommittedMemory());
+ PrintF("maximum_committed_by_old_data_space=%" V8_PTR_PREFIX "d ",
+ old_pointer_space_->MaximumCommittedMemory());
+ PrintF("maximum_committed_by_old_data_space=%" V8_PTR_PREFIX "d ",
+ old_pointer_space_->MaximumCommittedMemory());
+ PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ",
+ code_space_->MaximumCommittedMemory());
+ PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ",
+ map_space_->MaximumCommittedMemory());
+ PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ",
+ cell_space_->MaximumCommittedMemory());
+ PrintF("maximum_committed_by_property_space=%" V8_PTR_PREFIX "d ",
+ property_cell_space_->MaximumCommittedMemory());
+ PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ",
+ lo_space_->MaximumCommittedMemory());
+ PrintF("\n\n");
+ }
+
TearDownArrayBuffers();
isolate_->global_handles()->TearDown();
// Returns the amount of phyical memory currently committed for the heap.
size_t CommittedPhysicalMemory();
+ // Returns the maximum amount of memory ever committed for the heap.
+ intptr_t MaximumCommittedMemory() { return maximum_committed_; }
+
+ // Updates the maximum committed memory for the heap. Should be called
+ // whenever a space grows.
+ void UpdateMaximumCommitted();
+
// Returns the available bytes in space w/o growing.
// Heap doesn't guarantee that it can allocate an object that requires
// all available bytes. Check MaxHeapObjectSize() instead.
int initial_semispace_size_;
intptr_t max_old_generation_size_;
intptr_t max_executable_size_;
+ intptr_t maximum_committed_;
// For keeping track of how much data has survived
// scavenge since last new space expansion.
}
+void PagedSpace::IncreaseCapacity(int size) {
+ accounting_stats_.ExpandSpace(size);
+}
+
+
void PagedSpace::ReleasePage(Page* page, bool unlink) {
ASSERT(page->LiveBytes() == 0);
ASSERT(AreaSize() == page->area_size());
initial_capacity_ = RoundDown(initial_capacity, Page::kPageSize);
capacity_ = initial_capacity;
maximum_capacity_ = RoundDown(maximum_capacity, Page::kPageSize);
+ maximum_committed_ = 0;
committed_ = false;
start_ = start;
address_mask_ = ~(maximum_capacity - 1);
current = new_page;
}
+ SetCapacity(capacity_);
committed_ = true;
Reset();
return true;
start_ + capacity_, delta, executable())) {
return false;
}
- capacity_ = new_capacity;
+ SetCapacity(new_capacity);
NewSpacePage* last_page = anchor()->prev_page();
ASSERT(last_page != anchor());
for (int i = pages_before; i < pages_after; i++) {
ASSERT((current_page_ >= first_page()) && (current_page_ <= new_last_page));
}
- capacity_ = new_capacity;
+ SetCapacity(new_capacity);
return true;
}
}
+void SemiSpace::SetCapacity(int new_capacity) {
+ capacity_ = new_capacity;
+ if (capacity_ > maximum_committed_) {
+ maximum_committed_ = capacity_;
+ }
+}
+
+
void SemiSpace::set_age_mark(Address mark) {
ASSERT(NewSpacePage::FromLimit(mark)->semi_space() == this);
age_mark_ = mark;
bool LargeObjectSpace::SetUp() {
first_page_ = NULL;
size_ = 0;
+ maximum_committed_ = 0;
page_count_ = 0;
objects_size_ = 0;
chunk_map_.Clear();
page->set_next_page(first_page_);
first_page_ = page;
+ if (size_ > maximum_committed_) {
+ maximum_committed_ = size_;
+ }
+
// Register all MemoryChunk::kAlignment-aligned chunks covered by
// this large page in the chunk map.
uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment;
// Zero out all the allocation statistics (i.e., no capacity).
void Clear() {
capacity_ = 0;
+ max_capacity_ = 0;
size_ = 0;
waste_ = 0;
}
// Accessors for the allocation statistics.
intptr_t Capacity() { return capacity_; }
+ intptr_t MaxCapacity() { return max_capacity_; }
intptr_t Size() { return size_; }
intptr_t Waste() { return waste_; }
void ExpandSpace(int size_in_bytes) {
capacity_ += size_in_bytes;
size_ += size_in_bytes;
+ if (capacity_ > max_capacity_) {
+ max_capacity_ = capacity_;
+ }
ASSERT(size_ >= 0);
}
private:
intptr_t capacity_;
+ intptr_t max_capacity_;
intptr_t size_;
intptr_t waste_;
};
// spaces this equals the capacity.
intptr_t CommittedMemory() { return Capacity(); }
+ // The maximum amount of memory ever committed for this space.
+ intptr_t MaximumCommittedMemory() { return accounting_stats_.MaxCapacity(); }
+
// Approximate amount of physical memory committed for this space.
size_t CommittedPhysicalMemory();
accounting_stats_.AllocateBytes(bytes);
}
- void IncreaseCapacity(int size) {
- accounting_stats_.ExpandSpace(size);
- }
+ void IncreaseCapacity(int size);
// Releases an unused page and shrinks the space.
void ReleasePage(Page* page, bool unlink);
static void Swap(SemiSpace* from, SemiSpace* to);
+ // Returns the maximum amount of memory ever committed by the semi space.
+ size_t MaximumCommittedMemory() { return maximum_committed_; }
+
// Approximate amount of physical memory committed for this space.
size_t CommittedPhysicalMemory();
// Copies the flags into the masked positions on all pages in the space.
void FlipPages(intptr_t flags, intptr_t flag_mask);
+ // Updates Capacity and MaximumCommitted based on new capacity.
+ void SetCapacity(int new_capacity);
+
NewSpacePage* anchor() { return &anchor_; }
// The current and maximum capacity of the space.
int maximum_capacity_;
int initial_capacity_;
+ intptr_t maximum_committed_;
+
// The start address of the space.
Address start_;
// Used to govern object promotion during mark-compact collection.
return Capacity();
}
+ // Return the total amount of memory committed for new space.
+ intptr_t MaximumCommittedMemory() {
+ return to_space_.MaximumCommittedMemory() +
+ from_space_.MaximumCommittedMemory();
+ }
+
// Approximate amount of physical memory committed for this space.
size_t CommittedPhysicalMemory();
return objects_size_;
}
+ intptr_t MaximumCommittedMemory() {
+ return maximum_committed_;
+ }
+
intptr_t CommittedMemory() {
return Size();
}
private:
intptr_t max_capacity_;
+ intptr_t maximum_committed_;
// The head of the linked list of large object chunks.
LargePage* first_page_;
intptr_t size_; // allocated bytes
V8.MemoryHeapSamplePropertyCellSpaceCommitted) \
HM(heap_sample_code_space_committed, \
V8.MemoryHeapSampleCodeSpaceCommitted) \
+ HM(heap_sample_maximum_committed, \
+ V8.MemoryHeapSampleMaximumCommitted) \
// WARNING: STATS_COUNTER_LIST_* is a very large macro that is causing MSVC