V
V
Vladimir Abramov2013-09-09 23:19:05
Android
Vladimir Abramov, 2013-09-09 23:19:05

Frequent VMDebug.startGC() when creating bitmap?

My application is actively creating a Bitmap from a bytearray or embedded resources.
After testing on different devices, I found that the performance differs significantly on Lenovo IconTab and Samsung sgs3 or Tab 10.1
After running the profiler, I was surprised to find that the call time to Bitmap.nativeCreate() differs significantly if on lenovo it is deep below, then on samsungs at 3 place. Moreover, 97% of the processor time inside it is occupied by VMDebug.startGC() which, in theory, is supposed to be fake. On lenovo, I don't see this method.
I tried to run from Android Studio in debug and normal mode. I made release builds and filled them with my hands. Still, the performance is equally terrible.
Any ideas where to dig here and what to see?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgenij_Popovich, 2013-10-09
@Evgenij_Popovich

1. Why decode all 100 pictures at once and keep them in memory, and not as they appear on the screen?
2. Use decoding options so that pictures do not reserve memory for a long time

final  BitmapFactory. Options  options  =  new  BitmapFactory. options ( ) ;
 
// Decode bitmap with inSampleSize set
options. inJustDecodeBounds  =  false ;
 
// #302 added to reduce the amount of OutOfMemory errors
options. inDither  =  false ;  // Disable Dithering mode
options. inPurgeable  =  true ;  // Tell to gc that whether it needs
                            // free memory, the Bitmap can be
                            // cleared
options. inputShareable  =  true ; // Which kind of reference will
                                 // be used to recover the Bitmap
                                 // data after being clear, when
                                 // it will be used in the future
options. inTempStorage  =  new  byte [ 32  *  1024 ] ;

3. Consumed memory can be viewed on the Heap view tab. You don't see it on your screenshots.

E
Evgenij_Popovich, 2013-10-09
@Evgenij_Popovich

missed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question