Timob 14772: Fix memory leak

Test with appcelerator/titanium_mobile#4718. 
Testing steps in JIRA