Add a trace_gc_verbose flag.
The flag is only turned on when --trace_gc is one. It prints out used and available bytes in each space. To enable it, ENABLE_LOGGING_AND_PROFILING must be defined. This is a mini version of --heap_stats, but don't need DEBUG macro to be turned on. Review URL: http://codereview.chromium.org/149568 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2449 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
3e4c457d1c
commit
d52990b2e2
@ -158,6 +158,8 @@ DEFINE_bool(gc_global, false, "always perform global GCs")
|
||||
DEFINE_int(gc_interval, -1, "garbage collect after <n> allocations")
|
||||
DEFINE_bool(trace_gc, false,
|
||||
"print one trace line following each garbage collection")
|
||||
DEFINE_bool(trace_gc_verbose, false,
|
||||
"print more details following each garbage collection")
|
||||
DEFINE_bool(collect_maps, true,
|
||||
"garbage collect maps from which no objects can be reached")
|
||||
|
||||
|
25
src/heap.cc
25
src/heap.cc
@ -207,6 +207,27 @@ void Heap::ReportStatisticsBeforeGC() {
|
||||
}
|
||||
|
||||
|
||||
#if defined(ENABLE_LOGGING_AND_PROFILING)
|
||||
void Heap::PrintShortHeapStatistics() {
|
||||
if (!FLAG_trace_gc_verbose) return;
|
||||
PrintF("Memory allocator, used: %8d, available: %8d\n",
|
||||
MemoryAllocator::Size(), MemoryAllocator::Available());
|
||||
PrintF("New space, used: %8d, available: %8d\n",
|
||||
Heap::new_space_.Size(), new_space_.Available());
|
||||
PrintF("Old pointers, used: %8d, available: %8d\n",
|
||||
old_pointer_space_->Size(), old_pointer_space_->Available());
|
||||
PrintF("Old data space, used: %8d, available: %8d\n",
|
||||
old_data_space_->Size(), old_data_space_->Available());
|
||||
PrintF("Code space, used: %8d, available: %8d\n",
|
||||
code_space_->Size(), code_space_->Available());
|
||||
PrintF("Map space, used: %8d, available: %8d\n",
|
||||
map_space_->Size(), map_space_->Available());
|
||||
PrintF("Large object space, used: %8d, avaialble: %8d\n",
|
||||
map_space_->Size(), map_space_->Available());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// TODO(1238405): Combine the infrastructure for --heap-stats and
|
||||
// --log-gc to avoid the complicated preprocessor and flag testing.
|
||||
void Heap::ReportStatisticsAfterGC() {
|
||||
@ -3620,6 +3641,10 @@ GCTracer::~GCTracer() {
|
||||
CollectorString(),
|
||||
start_size_, SizeOfHeapObjects(),
|
||||
static_cast<int>(OS::TimeCurrentMillis() - start_time_));
|
||||
|
||||
#if defined(ENABLE_LOGGING_AND_PROFILING)
|
||||
Heap::PrintShortHeapStatistics();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -733,6 +733,11 @@ class Heap : public AllStatic {
|
||||
static void ZapFromSpace();
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_LOGGING_AND_PROFILING)
|
||||
// Print short heap statistics.
|
||||
static void PrintShortHeapStatistics();
|
||||
#endif
|
||||
|
||||
// Makes a new symbol object
|
||||
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
|
||||
// failed.
|
||||
|
@ -393,6 +393,9 @@ class MemoryAllocator : public AllStatic {
|
||||
// Returns the maximum available bytes of heaps.
|
||||
static int Available() { return capacity_ < size_ ? 0 : capacity_ - size_; }
|
||||
|
||||
// Returns allocated spaces in bytes.
|
||||
static int Size() { return size_; }
|
||||
|
||||
// Returns maximum available bytes that the old space can have.
|
||||
static int MaxAvailable() {
|
||||
return (Available() / Page::kPageSize) * Page::kObjectAreaSize;
|
||||
|
Loading…
Reference in New Issue
Block a user