Commit 9ad94e6e authored by ssid's avatar ssid Committed by Commit bot

Adding total available size of heap in v8 isolate memory dump provider.

The total available size is now returned by GetHeapStatistics api.
This CL uses the value in the dump provider to show the value in
other_spaces segment of the memory dump.

BUG=481504

Review URL: https://codereview.chromium.org/1129403003

Cr-Commit-Position: refs/heads/master@{#329303}
parent 9f613059
...@@ -53,6 +53,7 @@ void V8IsolateMemoryDumpProvider::DumpMemoryStatistics( ...@@ -53,6 +53,7 @@ void V8IsolateMemoryDumpProvider::DumpMemoryStatistics(
size_t known_spaces_used_size = 0; size_t known_spaces_used_size = 0;
size_t known_spaces_size = 0; size_t known_spaces_size = 0;
size_t known_spaces_available_size = 0;
size_t number_of_spaces = isolate_holder_->isolate()->NumberOfHeapSpaces(); size_t number_of_spaces = isolate_holder_->isolate()->NumberOfHeapSpaces();
for (size_t space = 0; space < number_of_spaces; space++) { for (size_t space = 0; space < number_of_spaces; space++) {
v8::HeapSpaceStatistics space_statistics; v8::HeapSpaceStatistics space_statistics;
...@@ -60,9 +61,11 @@ void V8IsolateMemoryDumpProvider::DumpMemoryStatistics( ...@@ -60,9 +61,11 @@ void V8IsolateMemoryDumpProvider::DumpMemoryStatistics(
space); space);
const size_t space_size = space_statistics.space_size(); const size_t space_size = space_statistics.space_size();
const size_t space_used_size = space_statistics.space_used_size(); const size_t space_used_size = space_statistics.space_used_size();
size_t space_available_size = space_statistics.space_available_size();
known_spaces_size += space_size; known_spaces_size += space_size;
known_spaces_used_size += space_used_size; known_spaces_used_size += space_used_size;
known_spaces_available_size += space_available_size;
std::string allocator_name = std::string allocator_name =
base::StringPrintf("%s/%s_%p/%s/%s", kRootDumpName, kIsolateDumpName, base::StringPrintf("%s/%s_%p/%s/%s", kRootDumpName, kIsolateDumpName,
...@@ -74,14 +77,12 @@ void V8IsolateMemoryDumpProvider::DumpMemoryStatistics( ...@@ -74,14 +77,12 @@ void V8IsolateMemoryDumpProvider::DumpMemoryStatistics(
base::trace_event::MemoryAllocatorDump::kNameOuterSize, base::trace_event::MemoryAllocatorDump::kNameOuterSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes, space_size); base::trace_event::MemoryAllocatorDump::kUnitsBytes, space_size);
// TODO(ssid): Fix crbug.com/481504 to get the objects count of live objects
// after the last GC.
space_dump->AddScalar( space_dump->AddScalar(
base::trace_event::MemoryAllocatorDump::kNameInnerSize, base::trace_event::MemoryAllocatorDump::kNameInnerSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes, space_used_size); base::trace_event::MemoryAllocatorDump::kUnitsBytes, space_used_size);
space_dump->AddScalar(kAvailableSizeAttribute, space_dump->AddScalar(kAvailableSizeAttribute,
base::trace_event::MemoryAllocatorDump::kUnitsBytes, base::trace_event::MemoryAllocatorDump::kUnitsBytes,
space_statistics.space_available_size()); space_available_size);
} }
// Compute the rest of the memory, not accounted by the spaces above. // Compute the rest of the memory, not accounted by the spaces above.
std::string allocator_name = base::StringPrintf( std::string allocator_name = base::StringPrintf(
...@@ -102,7 +103,8 @@ void V8IsolateMemoryDumpProvider::DumpMemoryStatistics( ...@@ -102,7 +103,8 @@ void V8IsolateMemoryDumpProvider::DumpMemoryStatistics(
// heap. // heap.
other_spaces_dump->AddScalar( other_spaces_dump->AddScalar(
kAvailableSizeAttribute, kAvailableSizeAttribute,
base::trace_event::MemoryAllocatorDump::kUnitsBytes, 0); base::trace_event::MemoryAllocatorDump::kUnitsBytes,
heap_statistics.total_available_size() - known_spaces_available_size);
} }
} // namespace gin } // namespace gin
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment