1

I just have a little ListView containing all installed apps and their icons
but if there are too much Apps installed i run into outOfMemoryErrors while doing

Drawable app_icon = applicationInfoList.get(i).loadIcon(context.getPackageManager()));

that for every ListEntry (this line is written in my ListAdapter)

no problem so far, i understand why i ran into this error (too much icons loaded, too few vm heap)
but i had a look at the source code of androids ManageApplications Activity in the settings
and i never run in any of those oom errors while using the settings ManageApps
but the weird thing is that they do it EXACTLY THE SAME WAY

as you can see in their source here:
the ManageApplications activity
where the Drawable icon gets loaded
where it is set in the list view

but i really dont understand why do i get a oom and they dont?

asked Nov 21, 2013 at 20:00
2
  • Urgent, Did you solved it? Commented Jan 2, 2014 at 9:15
  • i have created a LruCache now that solved it. Commented Jan 2, 2014 at 18:41

2 Answers 2

1

Resize your icons into small images, you will be fine! (had this problem before, too)

answered Nov 21, 2013 at 20:02
Sign up to request clarification or add additional context in comments.

1 Comment

but it isn't done in the ManageApplications Activity - so where is the difference between my code and their code?
1

Solved it myself.
I'm now loading every image into a cache before using it.
If the cache gets full, the oldest element will be discarded,
so new ones can get cached. additionally im resizing my images into smaller icons.
that did it.

answered Jan 2, 2014 at 18:43

5 Comments

Congratulations, could you please share your code? Is that similar to Google's BitmapFun Demo?
It's good you solved it, but if you have already decided to keep the question, at least share the solution.
@SagiLow So haven't I done that? Re-read my Answer please. I have told you everyrhing I have done: Avoiding the Problem
@Malte Shmitz What kind of cache ? is it disk cache ? just a 'list' ? I think you wouldn't have mark this as an answer if it was someone else and not yourself
@SagiLow One shouldn't mark the perfect answer but the one which solves the problem best. And to answer your question: I have used the simple LruCache class from android and a scaling alogrithm which you can find everywhere on the Internet.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.