Autore Topic: OutOfMemory con GridView  (Letto 623 volte)

Offline Aryon Solutions S.r.l. - Paolo

  • Nuovo arrivato
  • *
  • Post: 42
  • Respect: +1
    • Mostra profilo
  • Dispositivo Android:
    Samsung next
  • Sistema operativo:
    Windows 7
OutOfMemory con GridView
« il: 01 Aprile 2013, 04:18:35 CEST »
0
Salve a tutti,
Ho un piccolo problema, mentre scorro la mia GridView piena di immagini (immagini caricate dalla mia sdCard con cursor = managedQuery(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection, null, null, null) ), circa a metà galleria, mi da un errore di outOfMemory
Codice (Java): [Seleziona]
04-01 04:02:38.389: E/dalvikvm-heap(5926): 786432-byte external allocation too large for this process.
04-01 04:02:38.429: E/GraphicsJNI(5926): VM won't let us allocate 786432 bytes
04-01 04:02:38.429: D/skia(5926): libjpeg error 105 <  Ss=%d, Se=%d, Ah=%d, Al=%d> from allocPixelRef [512 384]
04-01 04:02:38.429: D/skia(5926): --- decoder->decode returned false
04-01 04:02:38.429: D/AndroidRuntime(5926): Shutting down VM
04-01 04:02:38.429: W/dalvikvm(5926): threadid=1: thread exiting with uncaught exception (group=0x40018578)
04-01 04:02:38.439: E/AndroidRuntime(5926): FATAL EXCEPTION: main
04-01 04:02:38.439: E/AndroidRuntime(5926): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:573)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:439)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.graphics.drawable.Drawable.createFromStream(Drawable.java:657)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.widget.ImageView.resolveUri(ImageView.java:521)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.widget.ImageView.setImageURI(ImageView.java:305)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at com.mkyong.android.adapter.ImageAdapter.getView(ImageAdapter.java:80)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.widget.AbsListView.obtainView(AbsListView.java:1561)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.widget.GridView.makeAndAddView(GridView.java:1254)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.widget.GridView.makeRow(GridView.java:300)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.widget.GridView.fillDown(GridView.java:253)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.widget.GridView.fillGap(GridView.java:220)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.widget.AbsListView.trackMotionScroll(AbsListView.java:4126)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.widget.AbsListView$TwFlingRunnable.run(AbsListView.java:3359)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.os.Handler.handleCallback(Handler.java:587)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.os.Looper.loop(Looper.java:130)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at android.app.ActivityThread.main(ActivityThread.java:3687)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at java.lang.reflect.Method.invokeNative(Native Method)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at java.lang.reflect.Method.invoke(Method.java:507)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-01 04:02:38.439: E/AndroidRuntime(5926):     at dalvik.system.NativeStart.main(Native Method)

Offline Ricky`

  • Amministratore
  • Utente storico
  • *****
  • Post: 3489
  • Respect: +507
    • Github
    • Google+
    • rciovati
    • Mostra profilo
Re:OutOfMemory con GridView
« Risposta #1 il: 02 Aprile 2013, 09:27:23 CEST »
+1
Se vuoi capire come creare una galleria efficiente (risolvendo anche il tuo problema), dai un occhio alla prima parte di questo video:

Google I/O 2012 - Doing More With Less: Being a Good Android Citizen - YouTube