heapprofd allows you to attribute memory usage to functions for Android services and apps.
For documentation, see https://docs.perfetto.dev/#/heapprofd.
Googlers, for design doc see: http://goto.google.com/heapprofd-design.