I have a few EditTexts that do nothing. I skipped all listeners and filters to see the clear picture. EditText has the next structure:
EditText et1 = new EditText(this);
et1.setId(num+1);
RelativeLayout.LayoutParams etp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
etp.addRule(RelativeLayout.LEFT_OF,et2.getId());
etp.addRule(RelativeLayout.BELOW,et3.getId());
etp.setMargins(0, 0, 5, 5);
et1.setLayoutParams(etp);
et1.setBackgroundResource(R.drawable.someXMLDrawable);
RelativeLayout content = new RelativeLayout(this);
content.addView(et1);
When I'm clicking on EditText it runs garbage collector. If will click from one field to another I will get the next picture:
D/dalvikvm(387): GC_CONCURRENT freed 1513K, 43% free 10451K/18055K, paused 1ms+3ms
I/dalvikvm-heap(387): Grow heap (frag case) to 13.731MB for 1190416-byte allocation
D/dalvikvm(387): GC_CONCURRENT freed 1525K, 43% free 10451K/18055K, paused 2ms+2ms
I/dalvikvm-heap(387): Grow heap (frag case) to 13.729MB for 1190416-byte allocation
D/dalvikvm(387): GC_CONCURRENT freed 1438K, 42% free 10540K/18055K, paused 2ms+2ms
I/dalvikvm-heap(387): Grow heap (frag case) to 13.723MB for 1190416-byte allocation
D/dalvikvm(387): GC_CONCURRENT freed 1436K, 42% free 10540K/18055K, paused 2ms+3ms
I/dalvikvm-heap(387): Grow heap (frag case) to 13.720MB for 1190416-byte allocation
D/dalvikvm(387): GC_CONCURRENT freed 1432K, 42% free 10540K/18055K, paused 1ms+3ms
I/dalvikvm-heap(387): Grow heap (frag case) to 13.721MB for 1190416-byte allocation
D/dalvikvm(387): GC_CONCURRENT freed 1435K, 42% free 10540K/18055K, paused 2ms+3ms
D/dalvikvm(278): GC_CONCURRENT freed 1839K, 63% free 12684K/33863K, paused 7ms+3ms
D/dalvikvm(190): GC_CONCURRENT freed 1652K, 74% free 14590K/54343K, paused 5ms+10ms
D/dalvikvm(190): GC_CONCURRENT freed 234K, 71% free 16243K/54343K, paused 9ms+19ms
I/dalvikvm-heap(190): Grow heap (frag case) to 29.055MB for 6553616-byte allocation
D/dalvikvm(190): GC_CONCURRENT freed 22K, 55% free 24826K/54343K, paused 9ms+20ms
Is it a normal situation? Can I fix it somehow?
EDIT: I have a ViewPager. It contains Fragments. Fragments consists of empty RelativeLayout. When app starts it receives JSNO strings based on which buttons and edittexts are dynamically generated and added to RelativeLayout. As EditText or Button need a context it use "getActivity()" that returns the associated activity context. Sometimes I need to remove all Views from RelativeLayout and create new Views and as removed Views have reference to Activity it can be not cleaned by GC,I don't know exactly, it is another question (if someone know the answer, will be nice to hear).
So controls dynamically generated from JSON string and we do not know the exact amount of them. That what I want to do.
And the question is - Why GC starts every time when I click on EditText.