Don't release field of Activity When activity is closed with calling finish(), the finalize() method may not be called, the instance may stay in memory for re-use in future, but if memory is low, the activity will be released. So don't excpet GC to release field of Activity subclass, you must release them explicitly in onDestroy method. ie. public void onDestroy() { super.onDestroy(); m_textField = null; m_hashTable.clare(); m_hashTable = null; }
Send messages in a wrong way Correct: Message message = handler.obtainMessage(); //handler is an instance of type Handler //Set fields of message message.id = xxx message.obj = xxx ... message.sendToTarget(); Wrong: Message message = new Message();
message.id = xxx
message.obj = xxx
...
handler.sendMessage(message);
That forget to call close() method may cause memory leak
Cursor
IO Stream, such as InputStream/FileInputStream, OutputStream/FileOutputStream
Socket
Database
That forget to call clear() may cause memory leak
HashTable
Map and its subclass,
Collection and its subclass, such as List, ArrayList, LinkedList, Vector, Set, Stack, Queue,