Android -- Object Creation/Memory Allocation vs. Performance

Posted by borg17of20 on Stack Overflow See other posts from Stack Overflow or by borg17of20
Published on 2010-06-14T17:49:04Z Indexed on 2010/06/14 17:52 UTC
Read the original article Hit count: 200

Filed under:
|
|
|

Hello all,

This is probably an easy one. I have about 20 TextViews/ImageViews in my current project that I access like this:

((TextView)multiLayout.findViewById(R.id.GameBoard_Multi_Answer1_Text)).setText("");

//or

((ImageView)multiLayout.findViewById(R.id.GameBoard_Multi_Answer1_Right)).setVisibility(View.INVISIBLE);

My question is this, am I better off, from a performance standpoint, just assigning these object variables? Further, am I losing some performance to the constant "search" process that goes on as a part of the findViewById(...) method? (i.e. Does findsViewById(...) use some sort of hashtable/hashmap for look-ups or does it implement an iterative search over the view hierarchy?)

At present, my program never uses more than 2.5MB of RAM, so will assigning 20 or so more object variables drastically affect this? I don't think so, but I figured I'd ask.

Thanks.

© Stack Overflow or respective owner

Related posts about android

Related posts about Performance