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

Change-Id: Ie9e5cb62d5b8298c76785eac81889befa7e8c438