Note that there are some explanatory texts on larger screens.

plurals
  1. POMy Simple ListView app is leaking memory. What am I doing wrong?‏
    text
    copied!<p>First off, I did post this to the android google group first but its moderated and I'm not sure how long itll take to show up there so hoping someone here can help.</p> <p>I created a simple app with a ListView following the ListActivity examples I found on the net.</p> <p>The app has 2 activities with the first having a button to create the second. When i hit the close button on the second activity I would like it to release its memory (or at least allow it to be garbage collected). Currently it will never release.</p> <p>I must be doing something wrong here because the MyListActivity never gets released. Can anyone tell me if I am doing something wrong with the way my activities are created/destroyed? or if my usage of the ListView is wrong?</p> <p>Thanks.</p> <p>My App as a zip - <a href="http://www.mediafire.com/?l26o5hz2bmbwk6j" rel="nofollow">http://www.mediafire.com/?l26o5hz2bmbwk6j</a></p> <p>Screen Shot of Eclipse MAT showing the list activity never releasing memory - www.mediafire.com/?qr6ga0k</p> <pre><code>public class MyListActivity extends ListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listlayout); ListAdapter ada = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, GENRES); setListAdapter(ada); } @Override public void onDestroy() { super.onDestroy(); System.gc(); } public void ClickHandler(View target) { switch (target.getId()) { case R.id.LL_Btn1: finish(); break; } } private static final String[] GENRES = new String[] { "Action", "Adventure", "Animation", "Children", "Comedy", "Documentary", "Drama", "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" };} public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } public void ClickHandler(View target) { switch (target.getId()) { case R.id.M_Button01: Intent intent = new Intent(); intent.setClassName(MyListActivity.class.getPackage().getName(), MyListActivity.class.getName()); startActivity(intent); break; } }} </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload