2012年12月27日 星期四

Android - Memory leak note

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 message

a.removeMessages(0);
Message msg = a.obtainMessage();
a.sendMessage(msg);

2012年12月25日 星期二

Liunx - How to fix "/bin/sh : pushd : not found"

How to fix the "/bin/sh : pushd : not found" ?
Modify your sh file ...

#!/bin/sh

to

#!/bin/bash