Try to dynamically create the ImaveView. The snippet code is listed
below. It's not the solution just a hint. For testing you can call
also System.gc() after setContentView(new View(this)); But using it in
your code is not a good way. Read this
http://blog.javia.org/android-allocation-free-code-avoids-the-gc-freeze/
@Override
protected void onStart() {
super.onStart();
Log.v(TAG, "onStart");
setContentView(R.layout.main);
ImageView iv = new ImageView(this);
iv.setBackgroundResource(R.drawable.forest);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
startActivity(new Intent(FirstActivity.this,
SecondActivity.class));
}
});
LinearLayout ll = (LinearLayout)findViewById(R.id.first_ll);
ll.addView(iv);
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/first_ll"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
More links to read:
http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html
http://developer.android.com/guide/practices/design/performance.html
On 21 июн, 12:37, mladen <[email protected]> wrote:
> Hello,
> I am trying to optimize the memory usage of my application on Xoom. I
> have an activity, which contains large images, so I decided to remove the
> whole layout in onStop method and restore it in onStart. But the memory is
> not released. I used MAT tool to detect the memory leak. It seems like a
> reference to EditText is hold by Android system. How can I clear this
> reference? I attached a simple example. I am curios how the problem can be
> solved, I know that I can use different images for specific screen sizes. I
> also tested with Nexus S, but the problem doesn't exists on it.
>
> example.zip
> 2954KПросмотретьЗагрузить
--
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