Add memory leak tracing infrastructure and fix a memory leak.
am: 0f7de9479a

Change-Id: Ia07f8011f361f1d5f89cd3743e4a54409286f12f