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

Unified Diff: runtime/vm/service.cc

Issue 2795473003: [vm service] Collect garbage before getting native allocation samples (Closed)
Patch Set: Add test Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/observatory/tests/service/collect_all_garbage_test.dart ('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 528a825d7cce88a5a8ae14cf14d387e3232fa980..f4241bb996cbbb7a1a0eabe689732815c8eeda42 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -3265,6 +3265,9 @@ static bool GetNativeAllocationSamples(Thread* thread, JSONStream* js) {
Int64Parameter::Parse(js->LookupParam("timeOriginMicros"));
int64_t time_extent_micros =
Int64Parameter::Parse(js->LookupParam("timeExtentMicros"));
+#if defined(DEBUG)
+ Isolate::Current()->heap()->CollectAllGarbage();
+#endif
ProfilerService::PrintNativeAllocationJSON(js, tag_order, time_origin_micros,
time_extent_micros);
return true;
@@ -3321,6 +3324,25 @@ static bool GetAllocationProfile(Thread* thread, JSONStream* js) {
}
+static const MethodParameter* collect_all_garbage_params[] = {
+ RUNNABLE_ISOLATE_PARAMETER, NULL,
+};
+
+#if defined(DEBUG)
+static bool CollectAllGarbage(Thread* thread, JSONStream* js) {
+ Isolate* isolate = thread->isolate();
+ isolate->heap()->CollectAllGarbage();
+ PrintSuccess(js);
+ return true;
+}
+#else
+static bool CollectAllGarbage(Thread* thread, JSONStream* js) {
+ PrintSuccess(js);
+ return true;
+}
+#endif // defined(DEBUG)
+
+
static const MethodParameter* get_heap_map_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
};
@@ -4170,6 +4192,8 @@ static const ServiceMethodDescriptor service_methods_[] = {
set_vm_name_params },
{ "_setVMTimelineFlags", SetVMTimelineFlags,
set_vm_timeline_flags_params },
+ { "_collectAllGarbage", CollectAllGarbage,
+ collect_all_garbage_params },
};
// clang-format on
« no previous file with comments | « runtime/observatory/tests/service/collect_all_garbage_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698