How to avoid memory leak in handler?
<p>My library code will notify byte array to UI,which in turn   queued.Another thread will dequeue the byte array and using an instance of handler bundle the byte array and send message to update UI.</p>

<p>code snippet which use handler to update UI</p>

<pre><code>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();
            }

        }
</code></pre>

<p>but the thing is i am getting outofmemory exception after 5 to 10 minutes.
Using Eclipse MAT heap  dumps shows  90% of heap is occupied by the more instance of android.os.Message.</p>
