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

Unified Diff: runtime/vm/service.cc

Issue 2278223002: Prevent the allInstances array from creating spurious references on future heap queries. (Closed)
Patch Set: Created 4 years, 4 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/lib/src/elements/heap_snapshot.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 a0df953a460b0230b6351df8e457dfc315091596..fe730422d6ba4f73e48fe958c18db9e6b6227ba4 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -1961,13 +1961,16 @@ static bool PrintInboundReferences(Thread* thread,
intptr_t element_index = slot_offset.Value();
jselement.AddProperty("_parentWordOffset", element_index);
}
-
- // We nil out the array after generating the response to prevent
- // reporting suprious references when repeatedly looking for the
- // references to an object.
- path.SetAt(i * 2, Object::null_object());
}
}
+
+ // We nil out the array after generating the response to prevent
+ // reporting suprious references when repeatedly looking for the
+ // references to an object.
+ for (intptr_t i = 0; i < path.Length(); i++) {
+ path.SetAt(i, Object::null_object());
+ }
+
return true;
}
@@ -2079,8 +2082,8 @@ static bool PrintRetainingPath(Thread* thread,
// We nil out the array after generating the response to prevent
// reporting spurious references when looking for inbound references
// after looking for a retaining path.
- for (intptr_t i = 0; i < limit; ++i) {
- path.SetAt(i * 2, Object::null_object());
+ for (intptr_t i = 0; i < path.Length(); i++) {
+ path.SetAt(i, Object::null_object());
}
return true;
@@ -2386,23 +2389,24 @@ static bool GetInstances(Thread* thread, JSONStream* js) {
ObjectGraph graph(thread);
graph.IterateObjects(&visitor);
intptr_t count = visitor.count();
- if (count < limit) {
- // Truncate the list using utility method for GrowableObjectArray.
- GrowableObjectArray& wrapper = GrowableObjectArray::Handle(
- GrowableObjectArray::New(storage));
- wrapper.SetLength(count);
- storage = Array::MakeArray(wrapper);
- }
JSONObject jsobj(js);
jsobj.AddProperty("type", "InstanceSet");
jsobj.AddProperty("totalCount", count);
{
JSONArray samples(&jsobj, "samples");
- for (int i = 0; i < storage.Length(); i++) {
+ for (int i = 0; (i < storage.Length()) && (i < count); i++) {
const Object& sample = Object::Handle(storage.At(i));
samples.AddValue(sample);
}
}
+
+ // We nil out the array after generating the response to prevent
+ // reporting spurious references when looking for inbound references
+ // after looking at allInstances.
+ for (intptr_t i = 0; i < storage.Length(); i++) {
+ storage.SetAt(i, Object::null_object());
+ }
+
return true;
}
« no previous file with comments | « runtime/observatory/lib/src/elements/heap_snapshot.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698