{ "id": "171737", "key": "TIMOB-26091", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2018-06-05T08:12:43.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "updated": "2019-11-08T13:21:54.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*Issue Description:*\r\nI have an app where I am getting out of memory errors when \r\ntrying to scale down an image on Android. It doesn't happen every \r\nsingle time, but more times than not. What I am doing is taking the picture and then I want to resize it and upload it to a server using *ti.imagefactory.*\r\n\r\n*Test Environment:*\r\n{code}\r\nReal device: Huawei Y9 2018(android 8),HTC one android 4.4.2\r\nAppcelerator Command-Line Interface, version 7.0.3\r\nCopyright (c) 2014-2018, Appcelerator, Inc. All Rights Reserved.\r\n\r\nOperating System\r\n Name = Mac OS X\r\n Version = 10.13.2\r\n Architecture = 64bit\r\n CPUs = 4\r\n Memory = 8.0GB\r\n\r\nNode.js\r\n Node.js Version = 8.9.1\r\n npm Version = 5.5.1\r\n\r\nAppcelerator CLI\r\n Installer = 4.2.13\r\n Core Package = 7.0.3\r\n\r\nTitanium CLI\r\n CLI Version = 5.1.0\r\n node-appc Version = 0.2.44\r\n\r\nTitanium SDKs\r\n 7.1.1.GA\r\n Version = 7.1.1\r\n{code}\r\n\r\n*Test Code:* Check the [link|https://gist.github.com/MotiurRahman/f5f2392af6f010d22c0d199fa9545124].\r\n\r\n*Test Steps:*\r\n# Run the test code.\r\n# click the button and take pictures\r\n# Keep taking pictures until the log shows the out of memory error. Normally, the error occurs after taking 7 to 8 pictures.\r\n\r\n*Output:*\r\n\r\nOn *android 8* it does not reproduce. The error shows on android *4.4.3*. Here's the output for both the devices:\r\n\r\nFor console logs, check the [link|https://gist.github.com/jebunnaher/afe31413d47d899d4113b537e3d79cf6]\r\n\r\n\r\n\r\n", "attachment": [], "flagged": false, "summary": "Android:App shows out of memory error when trying to scale down an image using ti.imagefactory", "creator": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "subtasks": [], "reporter": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "environment": null, "comment": { "comments": [ { "id": "438333", "author": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "body": "[~morahman] This slightly reworked sample should get rid of the memory leak:\r\nhttps://gist.github.com/ypbnv/066245e8a5b4fc4c293a3df60e6c652c\r\n\r\nUsing directly {{e.media}} as a TiBlob to be passed as parameters for {{setImage}}, {{ImageFactory.imageAsResized}} and calculating reduced dimensions has the same result and goes easier on the memory allocation. \r\nAnother thing that I noticed is that here:\r\nhttps://gist.github.com/MotiurRahman/f5f2392af6f010d22c0d199fa9545124#file-app-js-L74\r\nThe parameter passed for the {{remove}} method on both ImageViews is an instance of TiBlob, but it expects an instance of TiView.\r\n\r\nAs for the memory leak itself - I don't think it is specific for the ImageFactory module. I was able to reproduce it without the module at all. Allocating multiple big chunks of memory in the {{success}} callback of {{showCamera}} seems to be the culprit. Doing the same work outside the callback works just fine, so I would recommend more complex usage of the camera result to be done outside the callback's context.", "updateAuthor": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "created": "2018-06-12T09:09:24.000+0000", "updated": "2018-06-12T09:19:51.000+0000" }, { "id": "438358", "author": { "name": "bwhitaker", "key": "bwhitaker", "displayName": "Bryan Whitaker ", "active": true, "timeZone": "America/Chicago" }, "body": "Thank you so much. Those changes and suggestions worked great for me. ", "updateAuthor": { "name": "bwhitaker", "key": "bwhitaker", "displayName": "Bryan Whitaker ", "active": true, "timeZone": "America/Chicago" }, "created": "2018-06-12T17:49:41.000+0000", "updated": "2018-06-12T17:49:41.000+0000" }, { "id": "438383", "author": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "body": "We have a work in progress about improving memory management with images. Once it is ready this ticket's test case will be tested once again for possible leaks.", "updateAuthor": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "created": "2018-06-13T08:51:53.000+0000", "updated": "2018-06-13T08:51:53.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }