1. Used the StringBuilder to avoid the memory leak:
Error :
for (int i=1; i<65535 i="i" p="p">{
String aaa = aaa + "test sting"; // this will have memory leak
String aaa = null;
}
Solution :
for (int i=1; i<65535 i="i" p="p">{
StringBuilder sb;
sb.append("test sting");
String aaa = sb.ToString();
sb.setLength(0);
}
2. Recycle the message65535>65535>
a.removeMessages(0);
Message msg = a.obtainMessage();
a.sendMessage(msg);
沒有留言:
張貼留言