Project: titanium
Issue TIMOB-16450: Android: imageAsResized is leaking memory
h4. Problem Description When using the imageAsResize function in blob, it will start eventually to fail with a warning message about no more memory available. h4. Test Code {code} var count = 0; var win = Ti.UI.createWindow({ backgroundImage : 'b1.png', layout : 'vertical' }); var closeBtn = Ti.UI.createButton({ title : 'close', top : '44dp', }); var resizeBtn = Ti.UI.createButton({ title : 'resize: ' + count, top : '20dp', }); var imageView = Ti.UI.createImageView({ width : '200dp', height : '200dp', }); //-- win.add(closeBtn); win.add(resizeBtn); win.add(imageView); //-- resizeBtn.addEventListener('click', function() { var f = Ti.Filesystem.getFile('b1.jpg'); var blob = f.read(); f = null; win.remove(imageView); imageView.view = null; imageView = null; imageView = Ti.UI.createImageView({ width : '200dp', height : '200dp',	}); imageView.image = blob.imageAsResized(960, 960); blob = null; win.add(imageView); count++; resizeBtn.title = 'resize: ' + count; }); closeBtn.addEventListener('click', function() { win.close(); }); win.open(); {code} h4. Attachments Check the attachments for b1.jpg h4. Steps to reproduce 1. Create mobile project (classic titanium) 2. Copy-Paste the code from the testcase into app.js 3. Copy bg1.jpg into Resources directory 4. Deploy into device 5. Click in resize until the image doesn't appear anymore. h4. Extra info when the image doesn't appear anymore, you will see a message in the console saying: {code} [ERROR] : TiBlob: (KrollRuntimeThread) [3227,231234] Unable to resize the image. Not enough memory: null [ERROR] : TiBlob: java.lang.OutOfMemoryError [ERROR] : TiBlob: android.graphics.Bitmap.nativeCreate(Native Method) [ERROR] : TiBlob: android.graphics.Bitmap.createBitmap(Bitmap.java:809) [ERROR] : TiBlob: android.graphics.Bitmap.createBitmap(Bitmap.java:786) [ERROR] : TiBlob: android.graphics.Bitmap.createBitmap(Bitmap.java:718) [ERROR] : TiBlob: android.graphics.Bitmap.createScaledBitmap(Bitmap.java:594) [ERROR] : TiBlob: org.appcelerator.titanium.TiBlob.imageAsResized(TiBlob.java:543) [ERROR] : TiBlob: org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method) [ERROR] : TiBlob: org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:64) [ERROR] : TiBlob: org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:884) [ERROR] : TiBlob: org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1107) [ERROR] : TiBlob: org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:327) [ERROR] : TiBlob: android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : TiBlob: android.os.Looper.loop(Looper.java:136) [ERROR] : TiBlob: org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) [INFO] : I/dalvikvm-heap: Grow heap (frag case) to 182.277MB for 1474561 {code} h4. Q&A Link http://developer.appcelerator.com/question/162431/android-memory-leaks
Story points: 8