From d2d94537b2d03f5d2798fd0c7cb7a4e8d0fb9fbe Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 24 Feb 2019 11:47:12 -0500 Subject: [PATCH] report: simplify heap space iteration PR-URL: https://github.com/nodejs/node/pull/26285 Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: James M Snell --- src/node_report.cc | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/node_report.cc b/src/node_report.cc index 59aa0657a97659..9f2a61be09372c 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -447,8 +447,7 @@ static void PrintGCStatistics(JSONWriter* writer, Isolate* isolate) { writer->json_objectstart("heapSpaces"); // Loop through heap spaces - size_t i; - for (i = 0; i < isolate->NumberOfHeapSpaces() - 1; i++) { + for (size_t i = 0; i < isolate->NumberOfHeapSpaces(); i++) { isolate->GetHeapSpaceStatistics(&v8_heap_space_stats, i); writer->json_objectstart(v8_heap_space_stats.space_name()); writer->json_keyvalue("memorySize", v8_heap_space_stats.space_size()); @@ -464,19 +463,7 @@ static void PrintGCStatistics(JSONWriter* writer, Isolate* isolate) { "available", v8_heap_space_stats.space_available_size()); writer->json_objectend(); } - isolate->GetHeapSpaceStatistics(&v8_heap_space_stats, i); - writer->json_objectstart(v8_heap_space_stats.space_name()); - writer->json_keyvalue("memorySize", v8_heap_space_stats.space_size()); - writer->json_keyvalue( - "committedMemory", v8_heap_space_stats.physical_space_size()); - writer->json_keyvalue( - "capacity", - v8_heap_space_stats.space_used_size() + - v8_heap_space_stats.space_available_size()); - writer->json_keyvalue("used", v8_heap_space_stats.space_used_size()); - writer->json_keyvalue( - "available", v8_heap_space_stats.space_available_size()); - writer->json_objectend(); + writer->json_objectend(); writer->json_objectend(); }