I have a TabLayout, under each tab there is a Fragment (I'm using ArrayPagerAdapter). I've noticed that when I switch many times from a tab to another, my memory usage increase a lot. From my heap snapshot, I can see there are a lot of AutoCompleteTextView instances.
So I am convinced that the problem could be here:
public class MyFragment {
...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
...
final MultiAutoCompleteTextView eInput = (MultiAutoCompleteTextView) v.findViewById(R.id.TextInput);
EditorListener mEditorListener = new EditorListener();
eInput.setOnEditorActionListener(mEditorListener);
eInput.addTextChangedListener(new WhitespaceWatcher());
eInput.setAdapter(mDictionaryAdapter);
eInput.setTokenizer(new SpaceTokenizer());
...
}
...
class EditorListener implements TextView.OnEditorActionListener
{
@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
...
MultiAutoCompleteTextView input = (MultiAutoCompleteTextView) textView.findViewById(R.id.TextInput);
...
}
}
...
}
But I can't understand where exactly the problem is.