Search code examples
androidperformancemedia-playergalleryuniversal-image-loader

Application performance with media


I have a gallery application which loads all the media (images, music and video) thumbnails. I'm using Universal Image loader to load the images with following configs

DisplayImageOptions mOptions = new DisplayImageOptions.Builder()
        .bitmapConfig(Bitmap.Config.RGB_565)
        .showStubImage(R.drawable.media)
        .showImageForEmptyUri(R.drawable.media)
        .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
        .showImageOnFail(R.drawable.media).cacheInMemory().cacheOnDisc()
        .build();

and

config = new ImageLoaderConfiguration.Builder(mContext).enableLogging()
        .discCache(new UnlimitedDiscCache(cacheDir))
        .threadPoolSize(10).build();

This app works flawlessly on a 2GB ram device. But what i have observed is than on lower ram devices, the application is really laggy. Could someone tell me if these configuration are fine? or do i need to alter something to gain better performance in low end devices?


Solution

  • I figured out the problem. cacheInMemory() was the problem. This will have performance problems in low end devices. or 1GB ram devices.
    Also i suggest you not to use unlimited cache. i.e UnlimitedDiscCache(cacheDir)).
    Use limited cache since it will take up lot of memory. In my case it was almost 1.2GB on my phone.
    Having altered these options. I'm having a good performance.