Timob 14772: Fix memory leak

Test with https://github.com/appcelerator/titanium_mobile/pull/4718. 
Testing steps in JIRA