android-memory

Calling finish() does not clear memory references to Activity

时光毁灭记忆、已成空白 提交于 2019-12-02 10:17:38
问题 In a simplified version of my app, I have two activities, A and B. Actvity A starts B, and after some work B calls finish(). Using the Memory Analyzer Tool on most devices (Galaxy Nexus running 4.2, Droid 4 running 4.0.4, and Droid 2 running 2.3.4) shows no trace of activity B, which is what I expected. But on Samsung S3 running 4.1.1, MAT shows activity B objects still around, due to paths to the following GC roots (weak/soft references excluded): Class Name | Shallow Heap | Retained Heap --

FATAL EXCEPTION: main java.lang.OutOfMemoryError at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)

余生颓废 提交于 2019-12-02 04:03:14
I keep getting this error when I run my app. The app will compile fine and once I start interacting with it (ImageSlider) sometimes it breaks and comes up with that message. LogCat 02-18 12:25:05.426: E/AndroidRuntime(4545): FATAL EXCEPTION: main 02-18 12:25:05.426: E/AndroidRuntime(4545): java.lang.OutOfMemoryError 02-18 12:25:05.426: E/AndroidRuntime(4545): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 02-18 12:25:05.426: E/AndroidRuntime(4545): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:493) 02-18 12:25:05.426: E/AndroidRuntime(4545): at android

FATAL EXCEPTION: main java.lang.OutOfMemoryError at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)

拟墨画扇 提交于 2019-12-01 09:19:31
问题 I keep getting this error when I run my app. The app will compile fine and once I start interacting with it (ImageSlider) sometimes it breaks and comes up with that message. LogCat 02-18 12:25:05.426: E/AndroidRuntime(4545): FATAL EXCEPTION: main 02-18 12:25:05.426: E/AndroidRuntime(4545): java.lang.OutOfMemoryError 02-18 12:25:05.426: E/AndroidRuntime(4545): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 02-18 12:25:05.426: E/AndroidRuntime(4545): at android.graphics

SharedElement and custom EnterTransition causes memory leak

走远了吗. 提交于 2019-11-29 09:32:07
问题 Having a shared element animation and also a custom enter animation causes the activity to leak. Any idea what might be the cause? 09-21 16:19:31.007 28269-31066/com.sample.android D/LeakCanary﹕ * com.feeln.android.activity.MovieDetailActivity has leaked: 09-21 16:19:31.007 28269-31066/com.sample.android D/LeakCanary﹕ * GC ROOT android.app.ActivityThread$ApplicationThread.this$0 09-21 16:19:31.007 28269-31066/com.sample.android D/LeakCanary﹕ * references android.app.ActivityThread.mActivities

Memory not freeing after fragment is removed

谁说胖子不能爱 提交于 2019-11-29 02:03:00
I have a Fragment which has a RecyclerView . In this RecyclerView , I may occasionally download and display images (loaded with Glide into ImageView . So when I open the Fragment , used memory may sometimes jump from around 30MB to around 100MB or even more. After the Activity that is holding the Fragment is finished, the memory does not free up. It stays the same as before. I checked Glide documentation and apparently we don't have to worry about freeing up Bitmaps in RecyclerView . This is a huge issue, because app often crashes due to OOM because of this. How should I correctly handle

Release Memory of Particular Activity when it is Destroyed

跟風遠走 提交于 2019-11-28 23:11:07
I have a launcher Activity that load and resize big bitmap as it's background when it opens. Whenever hit the back button, the Activity is destroyed . But I think the memory is not released yet. When I open back the app, hit the back button and open it again (repeatedly), I will get a OutOfMemoryError . I am sorry for this newbie question but I am wondering how do I release the memory whenever an Activity is destroyed ? @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); //MARK - movingBackgroundImageView

Release Memory of Particular Activity when it is Destroyed

自古美人都是妖i 提交于 2019-11-27 21:10:43
问题 I have a launcher Activity that load and resize big bitmap as it's background when it opens. Whenever hit the back button, the Activity is destroyed . But I think the memory is not released yet. When I open back the app, hit the back button and open it again (repeatedly), I will get a OutOfMemoryError . I am sorry for this newbie question but I am wondering how do I release the memory whenever an Activity is destroyed ? @Override protected void onCreate(Bundle savedInstanceState) { super

OutOfMemoryError although vm has enough free memory

自作多情 提交于 2019-11-27 16:38:28
问题 I am getting this weird OutOfMemoryError that occurs although the dalvikvm reports enough heap space. Logs: 12-09 14:16:05.527: D/dalvikvm(10040): GC_FOR_ALLOC freed 551K, 21% free 38000K/47687K, paused 173ms, total 173ms 12-09 14:16:05.527: I/dalvikvm-heap(10040): Grow heap (frag case) to 38.369MB for 858416-byte allocation 12-09 14:16:05.699: D/dalvikvm(10040): GC_FOR_ALLOC freed 6K, 21% free 38832K/48583K, paused 169ms, total 169ms 12-09 14:16:05.894: D/dalvikvm(10040): GC_FOR_ALLOC freed

Memory not freeing after fragment is removed

假装没事ソ 提交于 2019-11-27 16:22:28
问题 I have a Fragment which has a RecyclerView . In this RecyclerView , I may occasionally download and display images (loaded with Glide into ImageView . So when I open the Fragment , used memory may sometimes jump from around 30MB to around 100MB or even more. After the Activity that is holding the Fragment is finished, the memory does not free up. It stays the same as before. I checked Glide documentation and apparently we don't have to worry about freeing up Bitmaps in RecyclerView . This is

android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>

牧云@^-^@ 提交于 2019-11-27 08:52:23
I am developing a simple app. Just finished the home screen. If the orientation changes more than two times, it is throwing the error and application is force closing. My activity Code : public class PasswordActivity extends Activity implements OnClickListener { Button login; Button forgot; Button register; private static final String PREFERENCES = "prefs"; private static final String PREFERENCES_NAME = "pref_name"; SharedPreferences settings; private Cursor c; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); login=