You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Test fun `Updating first dominator through longer path after already updated to common ancestor denominator removes retained size`() {
hprofFile.dump {
val answer = string("42")
val life = "com.example.Life" instance { field["answer"] = answer }
val universe = "com.example.Universe" instance { field["answer"] = answer }
val everything = "com.example.Everything" watchedInstance {
field["life"] = life
field["universe"] = universe
}
val fiber = "com.example.Fiber" instance { field["life"] = life }
val towel = "com.example.Towel" instance { field["fiber"] = fiber }
"Hitchhiker" clazz {
staticField["guide"] = everything
staticField["practicalTool"] = towel
}
}
val everythingInstanceLeak = retainedInstances().single().leakTraces.first()
// Only "Universe" is dominated by "Everything", the watched instance.
// shallow size for "everything" is 2 refs (life + universe) => 8 bytes
// Universe has one ref: 4 bytes => 8 + 4 = 12.
// Instead we get 24 because the incorrect algorithm is including the answer string
// which is 4 bytes for int size, 2 bytes per char => 12 bytes
assertThat(everythingInstanceLeak.retainedObjectCount).isEqualTo(2)
}
The text was updated successfully, but these errors were encountered:
Context: https://androiddev.social/@py/113176281321505098
Repro:
The text was updated successfully, but these errors were encountered: