Report object size of classes.
This way we do not need to re-emit the size for every instance.
Test: flash and get heap dump of system_server
Change-Id: I3c1034dc55d1505c149b9ba19d8942fd1046e9dc
Bug: 143874090
Bug: 159806127
diff --git a/perfetto_hprof/perfetto_hprof.cc b/perfetto_hprof/perfetto_hprof.cc
index 3f5d06d..d397e8e 100644
--- a/perfetto_hprof/perfetto_hprof.cc
+++ b/perfetto_hprof/perfetto_hprof.cc
@@ -579,6 +579,7 @@
type_proto->set_class_name(PrettyType(klass));
type_proto->set_location_id(FindOrAppend(&interned_locations,
klass->GetLocation()));
+ type_proto->set_object_size(klass->GetObjectSize());
}
art::mirror::Class* klass = obj->GetClass();
@@ -606,7 +607,10 @@
writer.GetHeapGraph()->add_objects();
object_proto->set_id(GetObjectId(obj));
object_proto->set_type_id(class_id);
- object_proto->set_self_size(obj->SizeOf());
+
+ // Arrays / strings are magic and have an instance dependent size.
+ if (obj->SizeOf() != klass->GetObjectSize())
+ object_proto->set_self_size(obj->SizeOf());
std::vector<std::pair<std::string, art::mirror::Object*>>
referred_objects;