Chromium Code Reviews| Index: runtime/vm/service.cc |
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
| index 074c1925d405a6487bde5a710645c60f3e86e5fe..e40d39bea7f179a24628d539a1b7a84d7972fbf4 100644 |
| --- a/runtime/vm/service.cc |
| +++ b/runtime/vm/service.cc |
| @@ -2252,19 +2252,35 @@ 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. |
|
koda
2015/05/19 20:12:36
Add named constant for chunk size.
rmacnak
2015/05/19 22:16:08
Done.
|
| + intptr_t num_chunks = (stream.bytes_written() + (MB - 1)) / MB; |
| + 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("i", i); |
| + event.AddProperty("n", num_chunks); |
| + event.AddProperty("nodeCount", node_count); |
| + } |
| } |
| + const String& message = String::Handle(String::New(js.ToCString())); |
| + |
| + uint8_t* chunk_start = buffer + (i * MB); |
| + intptr_t chunk_size = (i + 1 == num_chunks) |
|
koda
2015/05/19 20:12:35
Does this do the right thing when the last chunk i
rmacnak
2015/05/19 22:16:08
No, fixed.
|
| + ? stream.bytes_written() % MB |
| + : MB; |
| + |
| + SendEvent(message, chunk_start, chunk_size); |
| } |
| - const String& message = String::Handle(String::New(js.ToCString())); |
| - SendEvent(message, buffer, stream.bytes_written()); |
| } |