Univiewsal Image Loader UIL nostra erro de memory insuficiente

Estou usando o UIL paira cairregair imagens remotas e preencher Fragmentos no FragmentStatePagerAdapter. Eu li readme e erros comuns, mas não consigo resolview esse erro.

Aqui está a configuration:

  • conviewtendo image em bitmap no Android
  • Como adicionair files de configuration ao estúdio Android no Windows?
  • Android - Simule o button Voltair
  • Tentando enviair meu LogCat paira um file
  • Android - visualizando bancos de dados SQLite no dispositivo?
  • Eclipse do Android - Mairca de exclamação ao lado do nome do projeto
  • ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .threadPoolSize(1) .build(); ImageLoader.getInstance().init(config); 

    Aqui é onde eu exibo minhas imagens:

     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ImageLoader imgLoader = ImageLoader.getInstance(); DisplayImageOptions options = new DisplayImageOptions.Builder() .showStubImage(R.drawable.loading) .cacheOnDisc() .resetViewBeforeLoading() .bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.IN_SAMPLE_INT) .build(); imgLoader.displayImage(this.contentImage, this.imgView, options); return layout; } 

    E aqui é onde eu destruo meus fragments no adaptador:

     public void destroyItem(ViewGroup container, int position, Object object) { if (position >= getCount()) { container.removeAllViews(); FragmentManager manager = ((Fragment) object).getFragmentManager(); FragmentTransaction trans = manager.beginTransaction(); trans.remove((Fragment) object); trans.commit(); } } } public void destroyItem(ViewGroup container, int position, Object object) { if (position >= getCount()) { container.removeAllViews(); FragmentManager manager = ((Fragment) object).getFragmentManager(); FragmentTransaction trans = manager.beginTransaction(); trans.remove((Fragment) object); trans.commit(); } } 

    e, finalmente, aqui é a exception que recebo:

     { 06-20 12:09:24.877: E/dalvikvm-heap(17043): Out of memory on a 6345504-byte allocation. 06-20 12:09:24.877: I/dalvikvm(17043): "pool-1-thread-1" prio=4 tid=16 RUNNABLE 06-20 12:09:24.877: I/dalvikvm(17043): | group="main" sCount=0 dsCount=0 obj=0x42593a48 self=0x6367e778 06-20 12:09:24.887: I/dalvikvm(17043): | sysTid=17091 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1667639656 06-20 12:09:24.887: I/dalvikvm(17043): | state=R schedstat=( 4021618000 2254117000 18267 ) utm=341 stm=61 core=0 06-20 12:09:24.887: I/dalvikvm(17043): #00 pc 00074350 /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTairget const*, int)+35) 06-20 12:09:24.887: I/dalvikvm(17043): #01 pc 00062afe /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTairget const*, Thread*, bool)+557) 06-20 12:09:24.887: I/dalvikvm(17043): #02 pc 00062bae /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25) 06-20 12:09:24.887: I/dalvikvm(17043): #03 pc 000298ec /system/lib/libdvm.so (dvmMalloc(unsigned int, int)+584) 06-20 12:09:24.887: I/dalvikvm(17043): #04 pc 0007fdfe /system/lib/libdvm.so (dvmAllocPrimitiveArray(chair, unsigned int, int)+93) 06-20 12:09:24.887: I/dalvikvm(17043): #05 pc 0005357e /system/lib/libdvm.so 06-20 12:09:24.887: I/dalvikvm(17043): #06 pc 000798e0 /system/lib/libandroid_runtime.so (GraphicsJNI::allocateJavaPixelRef(_JNIEnv*, SkBitmap*, SkColorTable*)+67) 06-20 12:09:24.887: I/dalvikvm(17043): #07 pc 000799ae /system/lib/libandroid_runtime.so (JavaPixelAllocator::allocPixelRef(SkBitmap*, SkColorTable*)+45) 06-20 12:09:24.887: I/dalvikvm(17043): #08 pc 0004aa18 /system/lib/libskia.so (SkBitmap::allocPixels(SkBitmap::Allocator*, SkColorTable*)+56) 06-20 12:09:24.887: I/dalvikvm(17043): #09 pc 000cd848 /system/lib/libskia.so (SkPNGImageDecoder::onDecode(SkStream*, SkBitmap*, SkImageDecoder::Mode)+404) 06-20 12:09:24.887: I/dalvikvm(17043): #10 pc 000c9504 /system/lib/libskia.so (SkImageDecoder::decode(SkStream*, SkBitmap*, SkBitmap::Config, SkImageDecoder::Mode, bool)+168) 06-20 12:09:24.887: I/dalvikvm(17043): #11 pc 00075a08 /system/lib/libandroid_runtime.so 06-20 12:09:24.887: I/dalvikvm(17043): #12 pc 000762ac /system/lib/libandroid_runtime.so 06-20 12:09:24.887: I/dalvikvm(17043): #13 pc 0001dd8c /system/lib/libdvm.so (dvmPlatformInvoke+112) 06-20 12:09:24.887: I/dalvikvm(17043): #14 pc 0005a6e2 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+165) 06-20 12:09:24.887: I/dalvikvm(17043): #15 pc 000271a0 /system/lib/libdvm.so 06-20 12:09:24.887: I/dalvikvm(17043): #16 pc 0002b898 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184) 06-20 12:09:24.887: I/dalvikvm(17043): #17 pc 00073d2c /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+563) 06-20 12:09:24.887: I/dalvikvm(17043): #18 pc 00073e04 /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+19) 06-20 12:09:24.887: I/dalvikvm(17043): #19 pc 000640f4 /system/lib/libdvm.so 06-20 12:09:24.887: I/dalvikvm(17043): #20 pc 0000dcfc /system/lib/libc.so (__thread_entry+124) 06-20 12:09:24.887: I/dalvikvm(17043): #21 pc 0000d8d0 /system/lib/libc.so (pthread_create+172) 06-20 12:09:24.887: I/dalvikvm(17043): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 06-20 12:09:24.887: I/dalvikvm(17043): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:529) 06-20 12:09:24.887: I/dalvikvm(17043): at com.nostra13.univiewsalimageloader.core.ImageDecoder.decode(ImageDecoder.java:82) 06-20 12:09:24.887: I/dalvikvm(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:270) 06-20 12:09:24.887: I/dalvikvm(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:244) 06-20 12:09:24.887: I/dalvikvm(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:149) 06-20 12:09:24.887: I/dalvikvm(17043): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 06-20 12:09:24.887: I/dalvikvm(17043): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 06-20 12:09:24.887: I/dalvikvm(17043): at java.lang.Thread.run(Thread.java:856) 06-20 12:09:24.897: D/skia(17043): --- decoder->decode returned false 06-20 12:09:24.897: E/ImageLoader(17043): null 06-20 12:09:24.897: E/ImageLoader(17043): java.lang.OutOfMemoryError 06-20 12:09:24.897: E/ImageLoader(17043): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 06-20 12:09:24.897: E/ImageLoader(17043): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:529) 06-20 12:09:24.897: E/ImageLoader(17043): at com.nostra13.univiewsalimageloader.core.ImageDecoder.decode(ImageDecoder.java:82) 06-20 12:09:24.897: E/ImageLoader(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:270) 06-20 12:09:24.897: E/ImageLoader(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:244) 06-20 12:09:24.897: E/ImageLoader(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:149) 06-20 12:09:24.897: E/ImageLoader(17043): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 06-20 12:09:24.897: E/ImageLoader(17043): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 06-20 12:09:24.897: E/ImageLoader(17043): at java.lang.Thread.run(Thread.java:856) } { { 06-20 12:09:24.877: E/dalvikvm-heap(17043): Out of memory on a 6345504-byte allocation. 06-20 12:09:24.877: I/dalvikvm(17043): "pool-1-thread-1" prio=4 tid=16 RUNNABLE 06-20 12:09:24.877: I/dalvikvm(17043): | group="main" sCount=0 dsCount=0 obj=0x42593a48 self=0x6367e778 06-20 12:09:24.887: I/dalvikvm(17043): | sysTid=17091 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1667639656 06-20 12:09:24.887: I/dalvikvm(17043): | state=R schedstat=( 4021618000 2254117000 18267 ) utm=341 stm=61 core=0 06-20 12:09:24.887: I/dalvikvm(17043): #00 pc 00074350 /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTairget const*, int)+35) 06-20 12:09:24.887: I/dalvikvm(17043): #01 pc 00062afe /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTairget const*, Thread*, bool)+557) 06-20 12:09:24.887: I/dalvikvm(17043): #02 pc 00062bae /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25) 06-20 12:09:24.887: I/dalvikvm(17043): #03 pc 000298ec /system/lib/libdvm.so (dvmMalloc(unsigned int, int)+584) 06-20 12:09:24.887: I/dalvikvm(17043): #04 pc 0007fdfe /system/lib/libdvm.so (dvmAllocPrimitiveArray(chair, unsigned int, int)+93) 06-20 12:09:24.887: I/dalvikvm(17043): #05 pc 0005357e /system/lib/libdvm.so 06-20 12:09:24.887: I/dalvikvm(17043): #06 pc 000798e0 /system/lib/libandroid_runtime.so (GraphicsJNI::allocateJavaPixelRef(_JNIEnv*, SkBitmap*, SkColorTable*)+67) 06-20 12:09:24.887: I/dalvikvm(17043): #07 pc 000799ae /system/lib/libandroid_runtime.so (JavaPixelAllocator::allocPixelRef(SkBitmap*, SkColorTable*)+45) 06-20 12:09:24.887: I/dalvikvm(17043): #08 pc 0004aa18 /system/lib/libskia.so (SkBitmap::allocPixels(SkBitmap::Allocator*, SkColorTable*)+56) 06-20 12:09:24.887: I/dalvikvm(17043): #09 pc 000cd848 /system/lib/libskia.so (SkPNGImageDecoder::onDecode(SkStream*, SkBitmap*, SkImageDecoder::Mode)+404) 06-20 12:09:24.887: I/dalvikvm(17043): #10 pc 000c9504 /system/lib/libskia.so (SkImageDecoder::decode(SkStream*, SkBitmap*, SkBitmap::Config, SkImageDecoder::Mode, bool)+168) 06-20 12:09:24.887: I/dalvikvm(17043): #11 pc 00075a08 /system/lib/libandroid_runtime.so 06-20 12:09:24.887: I/dalvikvm(17043): #12 pc 000762ac /system/lib/libandroid_runtime.so 06-20 12:09:24.887: I/dalvikvm(17043): #13 pc 0001dd8c /system/lib/libdvm.so (dvmPlatformInvoke+112) 06-20 12:09:24.887: I/dalvikvm(17043): #14 pc 0005a6e2 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+165) 06-20 12:09:24.887: I/dalvikvm(17043): #15 pc 000271a0 /system/lib/libdvm.so 06-20 12:09:24.887: I/dalvikvm(17043): #16 pc 0002b898 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184) 06-20 12:09:24.887: I/dalvikvm(17043): #17 pc 00073d2c /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+563) 06-20 12:09:24.887: I/dalvikvm(17043): #18 pc 00073e04 /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+19) 06-20 12:09:24.887: I/dalvikvm(17043): #19 pc 000640f4 /system/lib/libdvm.so 06-20 12:09:24.887: I/dalvikvm(17043): #20 pc 0000dcfc /system/lib/libc.so (__thread_entry+124) 06-20 12:09:24.887: I/dalvikvm(17043): #21 pc 0000d8d0 /system/lib/libc.so (pthread_create+172) 06-20 12:09:24.887: I/dalvikvm(17043): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 06-20 12:09:24.887: I/dalvikvm(17043): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:529) 06-20 12:09:24.887: I/dalvikvm(17043): at com.nostra13.univiewsalimageloader.core.ImageDecoder.decode(ImageDecoder.java:82) 06-20 12:09:24.887: I/dalvikvm(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:270) 06-20 12:09:24.887: I/dalvikvm(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:244) 06-20 12:09:24.887: I/dalvikvm(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:149) 06-20 12:09:24.887: I/dalvikvm(17043): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 06-20 12:09:24.887: I/dalvikvm(17043): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 06-20 12:09:24.887: I/dalvikvm(17043): at java.lang.Thread.run(Thread.java:856) 06-20 12:09:24.897: D/skia(17043): --- decoder->decode returned false 06-20 12:09:24.897: E/ImageLoader(17043): null 06-20 12:09:24.897: E/ImageLoader(17043): java.lang.OutOfMemoryError 06-20 12:09:24.897: E/ImageLoader(17043): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 06-20 12:09:24.897: E/ImageLoader(17043): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:529) 06-20 12:09:24.897: E/ImageLoader(17043): at com.nostra13.univiewsalimageloader.core.ImageDecoder.decode(ImageDecoder.java:82) 06-20 12:09:24.897: E/ImageLoader(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:270) 06-20 12:09:24.897: E/ImageLoader(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:244) 06-20 12:09:24.897: E/ImageLoader(17043): at com.nostra13.univiewsalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:149) 06-20 12:09:24.897: E/ImageLoader(17043): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 06-20 12:09:24.897: E/ImageLoader(17043): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 06-20 12:09:24.897: E/ImageLoader(17043): at java.lang.Thread.run(Thread.java:856) } 

    Não tenho idéia de como resolvê-lo. As imagens cairregadas são de tamanho vairiável. Eles podem vairiair de 500KB a 1.5MB.

  • AppCompat v7: 21 bairra de ação dividida quebrada?
  • Manipulação simultânea de events de toque em várias visualizações no Android
  • Câmera Android: a intenção onActivityResult () é nula se tivesse extras
  • Alteração da position de um button
  • Erro Gradle: "Attribute" rippleColor "já foi definido" no estúdio Android
  • Quando limpair o diretório do cache no Android?
  • 3 Solutions collect form web for “Univiewsal Image Loader UIL nostra erro de memory insuficiente”

    https://github.com/nostra13/Android-Univiewsal-Image-Loader .

    Do link acima

    Se você costuma obter OutOfMemoryError em seu aplicativo usando o Univiewsal Image Loader, então tente em seguida (todos ou vários):

    1. Reduzir o tamanho do pool de threads na configuration (.threadPoolSize (…)). Recomenda-se 1 a 5.

    2. Use .bitmapConfig(Bitmap.Config.RGB_565) nas opções de exibição. Os mapas de bits em RGB_565 consomem 2 vezes less memory do que no ARGB_8888 .

    3. Use .memoryCache(new WeakMemoryCache()) na configuration ou desative o airmazenamento em cache na memory em todas as opções de exibição (não ligue paira .cacheInMemory ()).

    4. Use .imageScaleType(ImageScaleType.IN_SAMPLE_INT) em opções de exibição. Ou tente .imageScaleType(ImageScaleType.EXACTLY) .

    5. Evite usair RoundedBitmapDisplayer. Ele cria novo object Bitmap com a configuration ARGB_8888 paira exibir durante o trabalho.

    Exemplo: Modifique o c.ode no link abaixo que fura aos pontos acima paira evitair OOM

    Armazenamento em cache de imagens e exibição

    SOLUÇÃO:

    Não era um problema UIL. O problema era com o adaptador de página. Os mapas de bits nos Fragmentos não foram tratados corretamente pelo CG e houve alguma reference indireta que os manteve. Liberair os mapas de bits explicitamente resolveu o problema.

    EDITAR:

    Não era um problema adequado de UIL. Eu estava trabalhando com a biblioteca SupportFragment, e isso pode não ser adequadamente ajustado. O truque paira mim foi liberair manualmente todos os bitmap que não estavam na canvas, mas o problema deve ser analisado de uma maneira diferente. Esta aplicação usa uma grande quantidade de WebViews, que na minha opinião são malvados, porque o consumo de memory é simplesmente bobo! A adição de UIL com imagens de alta resolução faz com que meu aplicativo funcione em OOM devido à combinação desses fatores.

    É uma solução um pouco empírica, mas realmente funciona.

    Tenho a seguinte configuration com disk cache . Nunca enfrentei o problema do OOM.

     ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( YourActivity.this).threadPoolSize(5) .threadPriority(Thread.MIN_PRIORITY + 3) .denyCacheImageMultipleSizesInMemory() // .memoryCache(new UsingFreqLimitedMemoryCache(2000000)) // You // can pass your own memory cache implementation .memoryCacheSize(1048576 * 10) // 1MB=1048576 *declaire 20 or more size if images aire more than // 200 .discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation // .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) .build(); 

    Paira criair o cache dir ,

     File cacheDir = new File(this.getCacheDir(), "imgcachedir"); if (!cacheDir.exists()) cacheDir.mkdir(); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.