Application performance with media - android

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?

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.

Related

How should I address this crashing problem?

I recently created an android application, and after I completely redid my spinner dropdown menus using a custom adapter, some devices are crashing. It's very minimal, like 3 people have experienced crashes ever, but still it's something I want to address if possible because the apps minimum SDK version is as low as 16, so I imagine it's older devices that struggle the most. Attached is a pic of the crash report! This specific device has 2 GB of memory, you would think that would easily be enough to load a spinner with a bunch of low quality images right?
Thanks for the help in advance! This is the crash report: https://i.imgur.com/Wtm5pX9.jpg
The amount of memory the device has != the amount of memory you can use. The OS takes a lot. Other apps take a good amount. And even the memory you can use is fragmented into different pools. Generally "OutOfMemoryException" means out of Java heap memory (out of native memory would be a different crash, for example). Bitmap memory goes into different buckets on different OS versions, they've changed it a few times. So it could be a variety of reasons- you have too large an image that's using insane memory, your have leaks, you have sufficient memory on the device but the heap allocation spiked for some reason, your network layer isn't efficient (if you use Volley to download images its particularly stupid about that). There's not enough info here to actually give you a suggestion. I'd try to replicate it on a simulator with the RAM purposely capped at 1GB or smaller and see if you can reproduce it.

Android AIR application developed in Flash CS6 did not run smoothly on mobile phone

I have developed AIR application for Android in Flash CS6.
But the problem is, the application doesn't run smoothly on mobile phone.
I can't find the solution to my problem. Is it because of too many scenes or too many key frames in a scene?
Thank you so much for the explanation.
at first, take a look at this
when you find issues with only phones, it means that device is not enough strong to execute and render your app as fast as you want:
i know following points strongly change your performance in phone devices
using complex vectors, and trying to update them each frame (scale
is most harmful case)
high definition screen resolution of device (in this case you must avoid full-screen if necessary)
using CPU as render target, it must be changed to GPU (not even
direct)
a 24-30 fps would be best because you have more chance to play and
create everything with same speed as runtime fps
memory management and garbage collection
using bitmap objects instead vector graphics, you can keep storing
vectors in your app for advantage of reducing disk size, but its
possible to rasterizing them in runtime and letting CPU breathing
easily

Is there a way around low ram application limit?

I have application which in one method needs to load 2 large bitmaps, mask bitmap and perform masking process. It works fine until device has 16 MB ram limit.
My question is - are there any libraries that will allow using internal storage on specific method in case of overflow on heap memory?
If the bitmaps are used for display on the screen try downsizing them on decode.
BitmapFactory.Options.SampleSize
If that is not an option you can try sacrificing some performance with
BitmapFactory.Options.inPurgeable = true

Confusion with .cacheInMemory() vs .cacheOnDisc() in Universal Image Loader

I am using .cacheOnDisc() method for storing images in cache memory (Default method-Unlimited Extrenal Storage).should i enable cacheInMemory for my app?what r the effects will be if i dont use cacheInMemory option?
A memory cache caches the images in memory (RAM), i.e. it does not have to load and decode the image from internal storage because that is rather slow. You should IMO always use a memory cache.
The effect of not using memory cache can be - depending on implementation - that scrolling through lists of images is either stuttering or slower than necessary.
Disk (e.g. SD card) cache makes sense if the images are downloaded from the internets and you don't want to re-download them each time the app starts again. Local storage is much faster than the internets but still much slower than memory.

Is there a way to see how much ram a android device has?

I'm trying to make a puzzle app. It has a scroll bar with images of all the different puzzles you can choos from. This bitmap takes up a lot of memory and cases the system to crash on my android smart phone, but works fine on my acer tablet.
If i scale down the size of the bitmap, it works fine. Now I'm using two different sizes to use, and uses the screen resultion to determine what size to use. This seems to work on all the devices i tested so far. But I'm afraid that a device with a large resolution may not have a lot of memory and my app will crash.
Is there a way to see how much ram the device has so i can use both resultion and memory to determin what size bitmap to use???
Is there a way to see how much ram the device has so i can use both resultion and memory to determin what size bitmap to use?
The device RAM does not matter. The available memory for your process matters.
To find out the memory class of your app, call getMemoryClass() on ActivityManager -- that basically returns the amount of available RAM for your process in MB.

Categories

Resources