In hprof, set string class instance size to that of an empty string.
Bug: 21066704
(cherry-picked from commit c99b900283296663a37bffe06ae5ca6453748e16)
Change-Id: I91fc397f8ea6bdec654eae51b82528ba5843532c
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index d0eb083..868cb23 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -981,7 +981,11 @@
// ClassObjects have their static fields appended, so aren't all the same size.
// But they're at least this size.
__ AddU4(sizeof(mirror::Class)); // instance size
- } else if (klass->IsArrayClass() || klass->IsStringClass() || klass->IsPrimitive()) {
+ } else if (klass->IsStringClass()) {
+ // Strings are variable length with character data at the end like arrays.
+ // This outputs the size of an empty string.
+ __ AddU4(sizeof(mirror::String));
+ } else if (klass->IsArrayClass() || klass->IsPrimitive()) {
__ AddU4(0);
} else {
__ AddU4(klass->GetObjectSize()); // instance size