2017-09-20 5 views
-4

J'ai rencontré un problème avec le chargement de tous les éléments au démarrage de RecyclerView et le déclenchement de plus de 200 charges d'images qui provoque OutOfMemoryException. J'utilise la manière habituelle de définir des éléments à l'adaptateur avec RecyclerView.ViewHolder.Samsung Galaxy S4 charge tous les éléments dans RecyclerView au démarrage

Samsung Galaxy détectés sur S4: GT-I9506 - Android version 5.0.1

Toute personne autre a trouvé cette question? Ont été rencontrés sur d'autres appareils aussi.

Modifier

Exception:

09-20 07:35:59.666 25016-25889/smartapp E/art: Throwing OutOfMemoryError "Failed to allocate a 172 byte allocation with 8 free bytes and 8B until OOM" (recursive case) 
09-20 07:35:59.686 25016-25889/smartapp E/art: "Picasso-/image-url” prio=5 tid=45 Runnable 
09-20 07:35:59.686 25016-25889/smartapp E/art: | group="main" sCount=0 dsCount=0 obj=0x133ad0e0 self=0xad5df000 
09-20 07:35:59.686 25016-25889/smartapp E/art: | sysTid=25889 nice=10 cgrp=apps/bg_non_interactive sched=0/0 handle=0xad52e300 
09-20 07:35:59.686 25016-25889/smartapp E/art: | state=R schedstat=(906109587 479948169 1066) utm=73 stm=17 core=1 HZ=100 
09-20 07:35:59.686 25016-25889/smartapp E/art: | stack=0x92c56000-0x92c58000 stackSize=1036KB 
09-20 07:35:59.686 25016-25889/smartapp E/art: | held mutexes= "mutator lock"(shared held) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:163) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at java.io.BufferedInputStream.read(BufferedInputStream.java:295) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at com.squareup.picasso.MarkableInputStream.read(MarkableInputStream.java:138) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at com.squareup.picasso.Utils.isWebPFile(Utils.java:324) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at com.squareup.picasso.BitmapHunter.decodeStream(BitmapHunter.java:122) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:217) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at java.lang.Thread.run(Thread.java:818) 
09-20 07:35:59.686 25016-25889/smartapp E/art:  at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:411) 


09-20 07:35:58.746 25016-25016/smartapp D/Picasso: Main  created  [R373] Request{https://image-url} 
09-20 07:35:58.746 25016-25016/smartapp D/Picasso: Main  created  [R374] Request{https://image-url} 
09-20 07:35:58.746 25016-25216/smartapp D/Picasso: Dispatcher enqueued  [R373]+1ms 
09-20 07:35:58.746 25016-25216/smartapp D/Picasso: Dispatcher enqueued  [R374]+1ms 
09-20 07:35:58.746 25016-25016/smartapp D/Picasso: Main  created  [R375] Request{https://image-url} 
09-20 07:35:58.786 25016-25889/smartapp I/art: Clamp target GC heap from 143MB to 128MB 
09-20 07:35:58.786 25016-25889/smartapp I/art: Alloc partial concurrent mark sweep GC freed 622(21KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 127MB/128MB, paused 891us total 54.100ms 
09-20 07:35:58.846 25016-25889/smartapp I/art: Clamp target GC heap from 143MB to 128MB 
09-20 07:35:58.846 25016-25889/smartapp I/art: Alloc concurrent mark sweep GC freed 17(704B) AllocSpace objects, 0(0B) LOS objects, 0% free, 127MB/128MB, paused 826us total 54.652ms 
09-20 07:35:58.846 25016-25889/smartapp I/art: Forcing collection of SoftReferences for 2MB allocation 
09-20 07:35:58.846 25016-25036/smartapp I/art: WaitForGcToComplete blocked for 120.065ms for cause Background 
09-20 07:35:58.846 25016-25891/smartapp I/art: WaitForGcToComplete blocked for 132.562ms for cause Alloc 
+0

pouvez-vous poster l'exception complète – Redman

+0

cela ne peut pas arriver. seuls les éléments sont chargés dans la vue recycleur qui sont visibles à la fois .... mais il peut y avoir un cas laissez supposer que vous avez 10 éléments sur recyclable visble et les images que vous utilisez sont des images lourdes ou très haute résolution –

+0

Oui, je savoir ... Cela devrait être le comportement habituel ... Mais de toute façon, cela ne se passe pas sur le téléphone Galaxy S4, mais en essayant sur un appareil S6, tout fonctionne comme prévu. – Henric

Répondre

0

Le problème était que le RecyclerView se trouvait à l'intérieur d'un ScrollView, qui a déclenché l'opération d'extraction de tous les articles ..! En supprimant simplement ScrollView en tant que parent, en le remplaçant par un LinearLayout, le lissage normal a été atteint.

Une erreur stupide, mais j'espère que quelqu'un d'autre peut apprendre de mon erreur.