Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: runtime/vm/service.cc

Issue 1124153006: Heap snapshot visualizations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: sync Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object_graph.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index fff5ad5340e80373d0603b51e4eb03da02775f7e..ca8a3a758234473c2a80612e4d958c0eca27267f 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -2309,21 +2309,39 @@ void Service::SendGraphEvent(Isolate* isolate) {
uint8_t* buffer = NULL;
WriteStream stream(&buffer, &allocator, 1 * MB);
ObjectGraph graph(isolate);
- graph.Serialize(&stream);
- JSONStream js;
- {
- JSONObject jsobj(&js);
+ intptr_t node_count = graph.Serialize(&stream);
+
+ // Chrome crashes receiving a single tens-of-megabytes blob, so send the
+ // snapshot in megabyte-sized chunks instead.
+ const intptr_t kChunkSize = 1 * MB;
+ intptr_t num_chunks =
+ (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize;
+ for (intptr_t i = 0; i < num_chunks; i++) {
+ JSONStream js;
{
- JSONObject event(&jsobj, "event");
- event.AddProperty("type", "ServiceEvent");
- event.AddProperty("eventType", "_Graph");
- event.AddProperty("isolate", isolate);
+ JSONObject jsobj(&js);
+ {
+ JSONObject event(&jsobj, "event");
+ event.AddProperty("type", "ServiceEvent");
+ event.AddProperty("eventType", "_Graph");
+ event.AddProperty("isolate", isolate);
+
+ event.AddProperty("chunkIndex", i);
+ event.AddProperty("chunkCount", num_chunks);
+ event.AddProperty("nodeCount", node_count);
+ }
+ jsobj.AddProperty("streamId", "_Graph");
}
- jsobj.AddProperty("streamId", "_Graph");
+
+ const String& message = String::Handle(String::New(js.ToCString()));
+
+ uint8_t* chunk_start = buffer + (i * kChunkSize);
+ intptr_t chunk_size = (i + 1 == num_chunks)
+ ? stream.bytes_written() - (i * kChunkSize)
+ : kChunkSize;
+
+ SendEventWithData("_Graph", "_Graph", message, chunk_start, chunk_size);
}
- const String& message = String::Handle(String::New(js.ToCString()));
- SendEventWithData("_Graph", "_Graph", message,
- buffer, stream.bytes_written());
}
« no previous file with comments | « runtime/vm/object_graph.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698