Write interned field last.

They are the least important in interpreting a heap graph, so keep them
last so they get dropped first.

Bug: 180735727
Change-Id: Ie7eac1adbadc2765e8391fe5327fc0f2d2448ea0
diff --git a/perfetto_hprof/perfetto_hprof.cc b/perfetto_hprof/perfetto_hprof.cc
index d951c18..ebba1e3 100644
--- a/perfetto_hprof/perfetto_hprof.cc
+++ b/perfetto_hprof/perfetto_hprof.cc
@@ -827,16 +827,6 @@
                   reference_object_ids->Reset();
                 });
 
-            for (const auto& p : interned_fields) {
-              const std::string& str = p.first;
-              uint64_t id = p.second;
-
-              perfetto::protos::pbzero::InternedString* field_proto =
-                writer.GetHeapGraph()->add_field_names();
-              field_proto->set_iid(id);
-              field_proto->set_str(
-                  reinterpret_cast<const uint8_t*>(str.c_str()), str.size());
-            }
             for (const auto& p : interned_locations) {
               const std::string& str = p.first;
               uint64_t id = p.second;
@@ -847,6 +837,16 @@
               location_proto->set_str(reinterpret_cast<const uint8_t*>(str.c_str()),
                                   str.size());
             }
+            for (const auto& p : interned_fields) {
+              const std::string& str = p.first;
+              uint64_t id = p.second;
+
+              perfetto::protos::pbzero::InternedString* field_proto =
+                writer.GetHeapGraph()->add_field_names();
+              field_proto->set_iid(id);
+              field_proto->set_str(
+                  reinterpret_cast<const uint8_t*>(str.c_str()), str.size());
+            }
 
             writer.Finalize();
             ctx.Flush([] {