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

Side by Side Diff: runtime/vm/service.cc

Issue 1811713002: Perform a full GC by default when requesting a heap snapshot. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 3251 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 3262
3263 static bool GetHeapMap(Thread* thread, JSONStream* js) { 3263 static bool GetHeapMap(Thread* thread, JSONStream* js) {
3264 Isolate* isolate = thread->isolate(); 3264 Isolate* isolate = thread->isolate();
3265 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); 3265 isolate->heap()->PrintHeapMapToJSONStream(isolate, js);
3266 return true; 3266 return true;
3267 } 3267 }
3268 3268
3269 3269
3270 static const MethodParameter* request_heap_snapshot_params[] = { 3270 static const MethodParameter* request_heap_snapshot_params[] = {
3271 RUNNABLE_ISOLATE_PARAMETER, 3271 RUNNABLE_ISOLATE_PARAMETER,
3272 new BoolParameter("collectGarbage", false /* not required */),
3272 NULL, 3273 NULL,
3273 }; 3274 };
3274 3275
3275 3276
3276 static bool RequestHeapSnapshot(Thread* thread, JSONStream* js) { 3277 static bool RequestHeapSnapshot(Thread* thread, JSONStream* js) {
3278 const bool collect_garbage =
3279 BoolParameter::Parse(js->LookupParam("collectGarbage"), true);
Cutch 2016/03/17 15:37:32 should the default be true?
rmacnak 2016/03/17 18:09:08 I think so.
3277 if (Service::graph_stream.enabled()) { 3280 if (Service::graph_stream.enabled()) {
3278 Service::SendGraphEvent(thread); 3281 Service::SendGraphEvent(thread, collect_garbage);
3279 } 3282 }
3280 // TODO(koda): Provide some id that ties this request to async response(s). 3283 // TODO(koda): Provide some id that ties this request to async response(s).
3281 JSONObject jsobj(js); 3284 JSONObject jsobj(js);
3282 jsobj.AddProperty("type", "OK"); 3285 jsobj.AddProperty("type", "OK");
3283 return true; 3286 return true;
3284 } 3287 }
3285 3288
3286 3289
3287 void Service::SendGraphEvent(Thread* thread) { 3290 void Service::SendGraphEvent(Thread* thread, bool collect_garbage) {
3288 uint8_t* buffer = NULL; 3291 uint8_t* buffer = NULL;
3289 WriteStream stream(&buffer, &allocator, 1 * MB); 3292 WriteStream stream(&buffer, &allocator, 1 * MB);
3290 ObjectGraph graph(thread); 3293 ObjectGraph graph(thread);
3291 intptr_t node_count = graph.Serialize(&stream); 3294 intptr_t node_count = graph.Serialize(&stream, collect_garbage);
3292 3295
3293 // Chrome crashes receiving a single tens-of-megabytes blob, so send the 3296 // Chrome crashes receiving a single tens-of-megabytes blob, so send the
3294 // snapshot in megabyte-sized chunks instead. 3297 // snapshot in megabyte-sized chunks instead.
3295 const intptr_t kChunkSize = 1 * MB; 3298 const intptr_t kChunkSize = 1 * MB;
3296 intptr_t num_chunks = 3299 intptr_t num_chunks =
3297 (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize; 3300 (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize;
3298 for (intptr_t i = 0; i < num_chunks; i++) { 3301 for (intptr_t i = 0; i < num_chunks; i++) {
3299 JSONStream js; 3302 JSONStream js;
3300 { 3303 {
3301 JSONObject jsobj(&js); 3304 JSONObject jsobj(&js);
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
4105 if (strcmp(method_name, method.name) == 0) { 4108 if (strcmp(method_name, method.name) == 0) {
4106 return &method; 4109 return &method;
4107 } 4110 }
4108 } 4111 }
4109 return NULL; 4112 return NULL;
4110 } 4113 }
4111 4114
4112 #endif // !PRODUCT 4115 #endif // !PRODUCT
4113 4116
4114 } // namespace dart 4117 } // namespace dart
OLDNEW
« runtime/observatory/lib/src/elements/heap_snapshot.dart ('K') | « runtime/vm/service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698