私は既に私の問題を解決するためにgoogleとここでstackoverflowを見つけようとしましたが、何も私の質問に答えることができませんでした。 sqliteデータベースを使用してリストビューにデータを設定します。また、リストビューの上には、別のアクティビティに切り替えることができるタブホストがあります。そのアクティビティに切り替えてからリストビューに戻ると、リークが検出されます。しかし、どんな試みがあっても、明らかに漏れがあります。誰かがその漏れを見つけるのを助けることができますか?ここでtabhostとlistview sqliteデータベースの原因リーク
は、リストビューの活動です:
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.contacts);
contactlist = (ListView) findViewById(R.id.list);
entry.open();
c = entry.getData();
startManagingCursor(c);
String[] from = new String[] {"_id", "firstname", "lastname"};
int[] to = new int[] {R.id.iVPI, R.id.tvfirstName, R.id.tvlastName};
adapter = new MySimpleCursorAdapter(this, R.layout.contacts_list_item, c, from, to);
contactlist.setAdapter(adapter);
contactlist.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
// TODO Auto-generated method stub
Intent intent = new Intent(contacts.this, contactsdetails.class);
Cursor cursor = (Cursor) adapter.getItem(position);
intent.putExtra("ID", cursor.getInt(cursor.getColumnIndex("_id")));
c.close();
startActivity(intent);
}
});
}
protected void onStart() {
super.onStart();
entry.open();
}
protected void onPause() {
super.onPause();
entry.close();
}
protected void onStop() {
super.onStop();
entry.close();
}
protected void onDestroy() {
super.onDestroy();
entry.close();
}
tabhostactivityは非常に簡単です:
th = getTabHost();
th.addTab(th.newTabSpec("tag1").setIndicator("Contacts", getResources().getDrawable(R.drawable.book)).setContent(new Intent(this, contacts.class)));
th.addTab(th.newTabSpec("tag2").setIndicator("Profile", getResources().getDrawable(R.drawable.mailbox)).setContent(new Intent(this, incomingcallpopup.class)));
th.setCurrentTab(0);
誰がリークを見つけることができますか?
ご協力いただきありがとうございます。
リークはどのように報告されていますか? eclipse用のMemory Analyzer Toolプラグインを試してみてください。これは、さらに多くのデータとともに漏れたオブジェクトを教えてくれます。 – Bondax