Merge "Update the code to avoid memory issues." am: 1174bce393

Change-Id: Ie7474ea815f75a38ce7fbe7d4a8823d5ebe28f6c