2

I encountered a memory leak with Samsung devices. If some activity has EditText this activity will be leaked. To show this I created a small test applications.

First Activity (called MyActivity) contains EditText and Button. By pressing a button you call finish() on first Activity and open second one.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    findViewById(R.id.goTo)).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
            Intent intent = new Intent(MyActivity.this, AnotherActivity.class);
            startActivity(intent);
        }
    });
}

When I am on second Activity I take a hprof. From Memory Analyzer I see that MyActivity is leaked because of reference from InputMethodManager

Screenshot from Memory Analyzer

This problem occurs only in Samsung S III and Tab devices. So there is no leak in Xperia P device and others. Please help how to bypass this error.

JJD
  • 50,076
  • 60
  • 203
  • 339
Robert
  • 3,471
  • 3
  • 21
  • 24

0 Answers0