{"action":"opened","issue":{"url":"https://api.github.com/repos/bumptech/glide/issues/3181","repository_url":"https://api.github.com/repos/bumptech/glide","labels_url":"https://api.github.com/repos/bumptech/glide/issues/3181/labels{/name}","comments_url":"https://api.github.com/repos/bumptech/glide/issues/3181/comments","events_url":"https://api.github.com/repos/bumptech/glide/issues/3181/events","html_url":"https://github.com/bumptech/glide/issues/3181","id":337947644,"node_id":"MDU6SXNzdWUzMzc5NDc2NDQ=","number":3181,"title":"Out of memory exception when loading large image","user":{"login":"mhdtouban","id":2502415,"node_id":"MDQ6VXNlcjI1MDI0MTU=","avatar_url":"https://avatars1.githubusercontent.com/u/2502415?v=4","gravatar_id":"","url":"https://api.github.com/users/mhdtouban","html_url":"https://github.com/mhdtouban","followers_url":"https://api.github.com/users/mhdtouban/followers","following_url":"https://api.github.com/users/mhdtouban/following{/other_user}","gists_url":"https://api.github.com/users/mhdtouban/gists{/gist_id}","starred_url":"https://api.github.com/users/mhdtouban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhdtouban/subscriptions","organizations_url":"https://api.github.com/users/mhdtouban/orgs","repos_url":"https://api.github.com/users/mhdtouban/repos","events_url":"https://api.github.com/users/mhdtouban/events{/privacy}","received_events_url":"https://api.github.com/users/mhdtouban/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-03T15:24:00Z","updated_at":"2018-07-03T15:24:00Z","closed_at":null,"author_association":"NONE","body":"Trying to load image from gallery whith large size  (3 mb or above) causing the crash.\r\n\r\n\r\n4.7.1 \r\nworks with okhttp3-1.4.0 \r\nfails on Galaxy S6 edge \r\n\r\ntrying to load image from gallery\r\n\r\n<!-- How do you use Glide?\r\nMake sure you include everything as is in your app's code:\r\nChanging a single method parameter can yield totally different results.\r\nPlease clarify any magic variables that appear in the code, for example: \"// `this` is a Fragment\"\r\n-->\r\n**Glide load line / `GlideModule**:\r\n            GlideApp.with(this@GetMeAnythingActivity).load(imageUri)\r\n                    .apply(RequestOptions.bitmapTransform(\r\n                            RoundedCorners(Utils.dpToPxInt(this@GetMeAnythingActivity, 7F))))\r\n                    .into(target)\r\n\r\n    private val target: BaseTarget<Drawable> = object : BaseTarget<Drawable>() {\r\n        override fun onResourceReady(drawable: Drawable, transition: Transition<in Drawable>?) {\r\n            val dp103 = Utils.dpToPxInt(this@GetMeAnythingActivity, 103F)\r\n            imageView.layoutParams.height = dp103\r\n\r\n            imageView.layoutParams.width = dp103\r\n            imageView.requestLayout()\r\n\r\n            linearLayout.background = null\r\n            imageView.scaleType = ImageView.ScaleType.FIT_XY\r\n            imageView.setImageDrawable(drawable)\r\n            imageViewClear.visibility = View.VISIBLE\r\n        }\r\n\r\n        override fun getSize(cb: SizeReadyCallback) {\r\n            cb.onSizeReady(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)\r\n        }\r\n\r\n        override fun removeCallback(cb: SizeReadyCallback) {}\r\n    }\r\n\r\n///\r\n\r\noverride fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {\r\n        super.onActivityResult(requestCode, resultCode, data)\r\n\r\n        if (resultCode == Activity.RESULT_OK)\r\n            EasyImage.handleActivityResult(requestCode, resultCode, data, this, object : DefaultCallback() {\r\n                override fun onImagePicked(imageFile: File?, source: EasyImage.ImageSource?, type: Int) {\r\n                    imageUri = Uri.fromFile(imageFile)\r\n                    loadImage(imageUri)\r\n                }\r\n\r\n                override fun onImagePickerError(e: Exception?, source: EasyImage.ImageSource?, type: Int) {\r\n                    Toast.makeText(this@GetMeAnythingActivity, e?.message, Toast.LENGTH_LONG).show()\r\n                }\r\n            })\r\n    }\r\n```\r\n\r\n**Stack trace / LogCat**:\r\n```\r\nW/Glide: Load failed for file:///data/user/0/com.ideatolife.butlr/cache/EasyImage/bcef9c92-49c5-4b0f-82b9-19d1271ac697.jpg with size [-2147483648x-2147483648]\r\n    class com.bumptech.glide.load.engine.GlideException: Failed to load resource\r\n    There were 2 causes:\r\n    java.lang.OutOfMemoryError(Failed to allocate a 63489036 byte allocation with 16772320 free bytes and 47MB until OOM)\r\n    com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream$InvalidMarkException(Mark has been invalidated, pos: 53817 markLimit: 65536)\r\n     call GlideException#logRootCauses(String) for more detail\r\n      Cause (1 of 4): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{FileInputStream->Object->Drawable}, LOCAL\r\n    There were 2 causes:\r\n    java.lang.OutOfMemoryError(Failed to allocate a 63489036 byte allocation with 16772320 free bytes and 47MB until OOM)\r\n    com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream$InvalidMarkException(Mark has been invalidated, pos: 53817 markLimit: 65536)\r\n     call GlideException#logRootCauses(String) for more detail\r\n        Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->GifDrawable->Drawable}\r\n        Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->Bitmap->Drawable}\r\n    There was 1 cause:\r\n    java.lang.OutOfMemoryError(Failed to allocate a 63489036 byte allocation with 16772320 free bytes and 47MB until OOM)\r\n     call GlideException#logRootCauses(String) for more detail\r\n          Cause (1 of 1): class java.lang.OutOfMemoryError: Failed to allocate a 63489036 byte allocation with 16772320 free bytes and 47MB until OOM\r\n        Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->BitmapDrawable->Drawable}\r\n    There was 1 cause:\r\n    com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream$InvalidMarkException(Mark has been invalidated, pos: 53817 markLimit: 65536)\r\n     call GlideException#logRootCauses(String) for more detail\r\n          Cause (1 of 1): class com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream$InvalidMarkException: Mark has been invalidated, pos: 53817 markLimit: 65536\r\n      Cause (2 of 4): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{ParcelFileDescriptor->Object->Drawable}, LOCAL\r\n        Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->Bitmap->Drawable}\r\n        Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->BitmapDrawable->Drawable}\r\n      Cause (3 of 4): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{AssetFileDescriptor->Object->Drawable}, LOCAL\r\n        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{AssetFileDescriptor->Bitmap->Drawable}\r\n      Cause (4 of 4): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{HierarchicalUri->Object->Drawable}, LOCAL\r\n        Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{HierarchicalUri->Drawable->Drawable}\r\n        Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{HierarchicalUri->Bitmap->Drawable}\r\n2018-07-03 18:15:42.750 13640-13640/com.ideatolife.butlr I/Glide: Root cause (1 of 2)\r\n    java.lang.OutOfMemoryError: Failed to allocate a 63489036 byte allocation with 16772320 free bytes and 47MB until OOM\r\n        at dalvik.system.VMRuntime.newNonMovableArray(Native Method)\r\n        at android.graphics.Bitmap.nativeCreate(Native Method)\r\n        at android.graphics.Bitmap.createBitmap(Bitmap.java:977)\r\n        at android.graphics.Bitmap.createBitmap(Bitmap.java:948)\r\n        at android.graphics.Bitmap.createBitmap(Bitmap.java:915)\r\n        at com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool.createBitmap(LruBitmapPool.java:149)\r\n        at com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool.get(LruBitmapPool.java:131)\r\n        at com.bumptech.glide.load.resource.bitmap.TransformationUtils.rotateImageExif(TransformationUtils.java:329)\r\n        at com.bumptech.glide.load.resource.bitmap.Downsampler.decodeFromWrappedStreams(Downsampler.java:315)\r\n        at com.bumptech.glide.load.resource.bitmap.Downsampler.decode(Downsampler.java:208)\r\n        at com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder.decode(StreamBitmapDecoder.java:62)\r\n        at com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder.decode(StreamBitmapDecoder.java:18)\r\n        at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:72)\r\n        at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:55)\r\n        at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:45)\r\n        at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:58)\r\n        at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:43)\r\n        at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:501)\r\n        at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:472)\r\n        at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:458)\r\n        at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:410)\r\n        at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:379)\r\n        at com.bumptech.glide.load.engine.SourceGenerator.onDataReady(SourceGenerator.java:112)\r\n        at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:52)\r\n        at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:62)\r\n        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:302)\r\n        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:272)\r\n        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:233)\r\n        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)\r\n        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)\r\n        at java.lang.Thread.run(Thread.java:762)\r\n        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)\r\n2018-07-03 18:15:42.751 13640-13640/com.ideatolife.butlr I/Glide: Root cause (2 of 2)\r\n    com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream$InvalidMarkException: Mark has been invalidated, pos: 53817 markLimit: 65536\r\n        at com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream.reset(RecyclableBufferedInputStream.java:354)\r\n        at com.bumptech.glide.load.data.InputStreamRewinder.rewindAndGet(InputStreamRewinder.java:29)\r\n        at com.bumptech.glide.load.data.InputStreamRewinder.rewindAndGet(InputStreamRewinder.java:14)\r\n        at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:69)\r\n        at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:55)\r\n        at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:45)\r\n        at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:58)\r\n        at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:43)\r\n        at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:501)\r\n        at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:472)\r\n        at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:458)\r\n        at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:410)\r\n        at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:379)\r\n        at com.bumptech.glide.load.engine.SourceGenerator.onDataReady(SourceGenerator.java:112)\r\n        at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:52)\r\n        at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:62)\r\n        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:302)\r\n        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:272)\r\n        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:233)\r\n        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)\r\n        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)\r\n        at java.lang.Thread.run(Thread.java:762)\r\n        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)\r\n2018-07-03 18:15:42.751 13640-13640/com.ideatolife.butlr D/ViewRootImpl@311d25[GetMeAnythingActivity]: MSG_WINDOW_FOCUS_CHANGED 0\r\n2018-07-03 18:15:42.753 13640-13640/com.ideatolife.butlr D/SEM_CLIP_SemClipboardManager: isCocktailBarDisplayed : false\r\n2018-07-03 18:15:42.754 13640-13863/com.ideatolife.butlr V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 801\r\n2018-07-03 18:15:42.756 13640-13863/com.ideatolife.butlr V/FA: Activity paused, time: 3120333526\r\n2018-07-03 18:15:42.883 13640-13640/com.ideatolife.butlr D/InputTransport: Input channel destroyed: fd=128\r\n2018-07-03 18:15:42.883 13640-13640/com.ideatolife.butlr W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection\r\n2018-07-03 18:15:42.884 13640-13640/com.ideatolife.butlr W/IInputConnectionWrapper: finishComposingText on inactive InputConnection\r\n2018-07-03 18:15:44.010 13640-13640/com.ideatolife.butlr W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior!\r\n2018-07-03 18:15:44.011 13640-13640/com.ideatolife.butlr W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior!\r\n2018-07-03 18:15:44.018 13640-13640/com.ideatolife.butlr D/ViewRootImpl@311d25[GetMeAnythingActivity]: mHardwareRenderer.destroy()#1\r\n2018-07-03 18:15:44.021 13640-13640/com.ideatolife.butlr D/ViewRootImpl@311d25[GetMeAnythingActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true\r\n2018-07-03 18:15:44.400 13640-13640/com.ideatolife.butlr D/ViewRootImpl@311d25[GetMeAnythingActivity]: mHardwareRenderer.destroy()#1\r\n2018-07-03 18:15:44.418 13640-13640/com.ideatolife.butlr D/ViewRootImpl@311d25[GetMeAnythingActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=false 0} surfaceGenerationChanged=false\r\n2018-07-03 18:15:47.755 13640-13863/com.ideatolife.butlr V/FA: Inactivity, disconnecting from the service\r\n2018-07-03 18:15:49.299 13640-15903/com.ideatolife.butlr D/skia: Encode PNG Singlethread :   16807693 us, width=2988, height=5312\r\n2018-07-03 18:15:52.050 13640-13640/com.ideatolife.butlr D/ViewRootImpl@311d25[GetMeAnythingActivity]: mHardwareRenderer.destroy()#1\r\n2018-07-03 18:15:52.081 13640-13640/com.ideatolife.butlr D/ViewRootImpl@311d25[GetMeAnythingActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=false 0} surfaceGenerationChanged=false\r\n2018-07-03 18:15:52.106 13640-13863/com.ideatolife.butlr V/FA: Connecting to remote service\r\n2018-07-03 18:15:52.111 13640-13863/com.ideatolife.butlr V/FA: Activity resumed, time: 3120342875\r\n2018-07-03 18:15:52.112 13640-13640/com.ideatolife.butlr W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior!\r\n2018-07-03 18:15:52.128 13640-13640/com.ideatolife.butlr D/ViewRootImpl@311d25[GetMeAnythingActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x7 surface={isValid=true 533007454208} surfaceGenerationChanged=true\r\n2018-07-03 18:15:52.128 13640-13640/com.ideatolife.butlr D/ViewRootImpl@311d25[GetMeAnythingActivity]: mHardwareRenderer.initialize() mSurface={isValid=true 533007454208} hwInitialized=true\r\n2018-07-03 18:15:52.130 13640-13968/com.ideatolife.butlr D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000,  [1080x1920]-format:1\r\n2018-07-03 18:15:52.156 13640-13640/com.ideatolife.butlr D/AndroidRuntime: Shutting down VM\r\n2018-07-03 18:15:52.203 13640-13640/com.ideatolife.butlr E/AndroidRuntime: FATAL EXCEPTION: main\r\n    Process: com.ideatolife.butlr, PID: 13640\r\n    java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@932de6d\r\n```"}}
{"actor":{"display_login":"mhdtouban"}}