2016-12-19 3 views
-3

So lösen Sie OutOfMemoryError in Glide Image Loading.OutOfMemoryError in Glide Image Loader

Caused by: java.lang.OutOfMemoryError: Failed to allocate a 5137932 byte allocation with 923120 free bytes and 901KB until OOMSent on:2:54 threw uncaught throwablejava.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Failed to allocate a 5137932 byte allocation with 923120 free bytes and 901KB until OOMat java.util.concurrent.FutureTask.report(FutureTask.java:94)at java.util.concurrent.FutureTask.get(FutureTask.java:164)at

com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor.afterExecute(FifoPriorityThreadPoolExecutor.java:96)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1121)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)at java.lang.Thread.run(Thread.java:818)at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)Caused by: java.lang.OutOfMemoryError: Failed to allocate a 5137932 byte allocation with 923120 free bytes and 901KB until OOMat dalvik.system.VMRuntime.newNonMovableArray(Native Method)at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:882)at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:858)at com.bumptech.glide.load.resource.bitmap.Downsampler.decodeStream(Downsampler.java:329)at com.bumptech.glide.load.resource.bitmap.Downsampler.downsampleWithSize(Downsampler.java:220)at com.bumptech.glide.load.resource.bitmap.Downsampler.decode(Downsampler.java:153)at com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder.decode(StreamBitmapDecoder.java:50)at com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder.decode(StreamBitmapDecoder.java:19)at com.bumptech.glide.load.resource.bitmap.ImageVideoBitmapDecoder.decode(ImageVideoBitmapDecoder.java:39)at com.bumptech.glide.load.resource.bitmap.ImageVideoBitmapDecoder.decode(ImageVideoBitmapDecoder.java:20)at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decodeBitmapWrapper(GifBitmapWrapperResourceDe

Glide Bild Loder-Code für das Laden von Bildern

Glide.with(activity) 
      .load(items.get(position).getCharacterImageId(activity.getResources()))     .placeholder(items.get(position).getColor(activity.getResources())) 
       .dontAnimate() 
       .thumbnail(0.7f) 
       .into(img_letter); 
+0

Verwenden Sie Emulator zum Testen? –

+0

Wir können Ihnen nicht wirklich helfen ohne Ihren Code – Neeeko

+0

Ich habe ein echtes Gerät zum Testen verwendet. –

Antwort

0
android:largeHeap="true" 

Verwenden Sie diese Zeile in der Manifest-Datei wie:

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:largeHeap="true" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 

Wenn das Problem dann nicht gelöst verwenden dies:

BitmapFactory.Options options = new BitmapFactory.Options(); 
options.inSampleSize = 8; 
mBitmapInsurance = BitmapFactory.decodeFile(mCurrentPhotoPath,options); 
+0

Ich habe auch android benutzt: largeHeap = "true". –

+0

Ich habe Glide verwendet, also BitmapFactory Option ist nicht hier, –

0

können Sie Android verwenden: largeHeap = „true“ eine größere Heap-Größe zu verlangen, aber das wird auf die zuvor in Honeycomb-Geräte nicht funktionieren. Auf Geräten mit Version 2.3 können Sie die VMRuntime-Klasse verwenden, dies funktioniert jedoch nicht bei Gingerbread und höher.

Verwandte Themen