0
내 라이브러리 코드는 바이트 배열을 UI에 대기열에 알립니다. 다른 스레드는 바이트 배열을 대기열에서 제외하고 핸들러 인스턴스를 사용하여 바이트 배열을 전달하고 메시지를 보내 UI를 업데이트합니다. 핸들러를 사용핸들러에서 메모리 누수를 피하는 방법은 무엇입니까?
코드는 UI
public void run(){
while(running){
try {
byte[] msg=(byte[]) queue.getMsg();
Message message=new Message();
Bundle bundle=new Bundle();
bundle.putByteArray("img",msg);
message.obj=bundle;
handler.sendMessage(message);
message=null;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
를 업데이트하지만 것은 내가 5 ~ 10 분에서 OutOfMemory 예외를 얻고있다. Eclipse MAT 힙 덤프를 사용하면 힙의 90 %가 android.os.Message의 인스턴스가 더 많이 차지하고 있음을 알 수 있습니다.