I have noticed memory leaks while there is more than 64MB memory
assigned on heap.
Please find attached the source code. I have compiled the progranmme
using API level 11.
Application has specified android:largeHeap="true" in its manifest.
Is there any solution/workaround to this problem?
public class LeakActivity extends Activity
{
private Vector<byte[]> m_field = null;
@Override
public void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.main );
Button btn;
btn = (Button) findViewById( R.id.b_alloc );
btn.setOnClickListener( new OnClickListener()
{
public void onClick( View a_view )
{
// for( int index = 0 ; index < 10 ; ++ index )
// no leak
for( int index = 0 ; index < 20 ; ++ index )
// ~20MB leak
{
byte[] item = new byte[ 4*1024*1024 ];
m_field.add( item );
}
Log.w( "LeakActivity", "allocate" );
}
} );
btn = (Button) findViewById( R.id.b_free );
btn.setOnClickListener( new OnClickListener()
{
public void onClick( View a_view )
{
m_field.clear();
Log.w( "LeakActivity", "release" );
}
} );
if( m_field == null )
{
m_field = new Vector<byte[]>();
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en