4

im reading android training article: Performance Tips

Object creation is never free. A generational garbage collector with per-thread allocation pools for temporary objects can make allocation cheaper, but allocating memory is always more expensive than not allocating memory.

what's per-thread allocation pools for temporary objects?

I did't find any docs about this.

bigkun
  • 61
  • 1
  • 1
  • 3
  • Please, note that all GC characteristics would not apply directly to Android. Though you code in Java, your .apk runs on a Dalvik machine not on a JVM. – Ravi K Thapliyal Jul 28 '13 at 16:47

2 Answers2

0

Read it as : A generational garbage collector with per-thread allocation , pools for temporary objects .

Per thread garbage collection is that Objects associated only with a thread that created them are tracked. At a garbage collection time for a particular thread, it is determined which objects associated only with that thread remain reachable from a restricted root set associated with the thread. Any thread-only objects that are not determined to be reachable are garbage collected.

AllTooSir
  • 48,828
  • 16
  • 130
  • 164
0

What they are saying, and they are right, is object creation (and subsequent collection) can be a major time-taker.

If you look at this example you'll see that at one point, memory management dominated the time, and was fixed by keeping used objects of each class in a free-list, so they could be efficiently re-used.

However, also note in that example, memory management was not the biggest problem at first. It only became the biggest problem after even bigger problems were removed.

For example, suppose you have a team of people who want to lose weight, relative to another team. Suppose the team has
1) a 400-lb person, (corresponding to some other problem)
2) a 200-lb person (corresponding to the memory management problem), and
3) a 100-lb person (corresponding to some other problem).
If the team as a whole wants to lose the most weight, where should it concentrate first?

Obviously, they need to work on all three, but if they miss out on the big guy, they're not going to get very far.

So the most aggressive procedure is first find out what the biggest problem is (not by guessing), and fix that. Then the next biggest, and so on.

The big secret is don't guess. Everybody knows that, but what do they do? - they guess anyway. Guesses, by definition, are often wrong, missing the biggest issues. Let the program tell you what the biggest problem is. (I use random pausing as in that example.)

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135