当我不断从横向移动到纵向时,我的应用程序会突然关闭而没有任何通知,反之亦然,从一个活动向另一个活动发送值时,我也会遇到同样的错误。这是我从 LogCat 得到的一些错误:
从不断移动的风景和肖像中记录
04-22 20:23:31.110: E/dalvikvm-heap(6275): 5891496-byte external allocation too large for this process.
04-22 20:23:31.120: E/dalvikvm(6275): Out of memory: Heap Size=5639KB, Allocated=3205KB, Bitmap Size=22062KB, Limit=32768KB
04-22 20:23:31.120: E/dalvikvm(6275): Trim info: Footprint=5639KB, Allowed Footprint=5639KB, Trimmed=496KB
04-22 20:23:31.120: E/GraphicsJNI(6275): VM won't let us allocate 5891496 bytes
记录不断从一个活动发送值到另一个活动
04-22 21:57:04.497: D/dalvikvm(9570): GC_EXTERNAL_ALLOC freed 19K, 47% free 2901K/5379K, external 1151K/1663K, paused 24ms
04-22 21:57:04.647: D/dalvikvm(9570): GC_EXTERNAL_ALLOC freed 85K, 45% free 2960K/5379K, external 2320K/2875K, paused 24ms
04-22 21:57:04.807: D/dalvikvm(9570): GC_EXTERNAL_ALLOC freed 2K, 45% free 2960K/5379K, external 8073K/10082K, paused 23ms
04-22 21:57:04.927: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@4053a410
04-22 21:57:04.937: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@405316d0
04-22 21:57:04.937: D/WindowManagerImpl(9570): addView, new view, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView@40515820
04-22 21:57:05.227: D/WindowManagerImpl(9570): finishRemoveViewLocked, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView@40522768
04-22 21:57:06.158: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:06.158: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:06.238: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@4054e1f0
04-22 21:57:06.529: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:06.529: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:06.549: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40559870
04-22 21:57:07.019: D/dalvikvm(9570): GC_EXTERNAL_ALLOC freed 83K, 45% free 3035K/5447K, external 13863K/15875K, paused 25ms
04-22 21:57:07.129: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:07.129: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:07.149: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40552178
04-22 21:57:07.289: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:07.289: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:07.369: D/dalvikvm(9570): GC_EXTERNAL_ALLOC freed 34K, 44% free 3058K/5447K, external 12711K/14759K, paused 26ms
04-22 21:57:07.600: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40534f78
04-22 21:57:08.050: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:08.050: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:08.050: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@4053da60
04-22 21:57:08.421: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:08.421: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:08.431: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@4055caf0
04-22 21:57:08.771: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:08.771: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:08.841: D/dalvikvm(9570): GC_EXTERNAL_ALLOC freed 55K, 44% free 3092K/5447K, external 18465K/18465K, paused 24ms
04-22 21:57:09.091: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40530708
04-22 21:57:09.201: D/dalvikvm(9570): GC_EXTERNAL_ALLOC freed 9K, 44% free 3093K/5447K, external 24218K/24218K, paused 24ms
04-22 21:57:09.321: D/dalvikvm(9570): GC_FOR_MALLOC freed <1K, 44% free 3092K/5447K, external 24218K/24218K, paused 17ms
04-22 21:57:09.341: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:09.341: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:09.351: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@4055df78
04-22 21:57:09.542: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:09.542: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:09.542: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40566488
04-22 21:57:09.692: D/dalvikvm(9570): GC_EXTERNAL_ALLOC freed 70K, 44% free 3098K/5511K, external 24218K/24218K, paused 30ms
04-22 21:57:09.812: D/dalvikvm(9570): GC_FOR_MALLOC freed 5K, 44% free 3093K/5511K, external 24218K/24218K, paused 17ms
04-22 21:57:09.872: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:09.872: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:09.882: D/ATRecorder(9570): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@4054bd48
04-22 21:57:10.312: D/View(9570): onTouchEvent: viewFlags: 0x18004081
04-22 21:57:10.312: D/View(9570): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
04-22 21:57:10.412: D/dalvikvm(9570): GC_EXTERNAL_ALLOC freed 51K, 44% free 3099K/5511K, external 24218K/24218K, paused 24ms
04-22 21:57:10.533: D/dalvikvm(9570): GC_FOR_MALLOC freed 3K, 44% free 3096K/5511K, external 24218K/24218K, paused 17ms
04-22 21:57:10.613: D/dalvikvm(9570): GC_EXTERNAL_ALLOC freed <1K, 44% free 3097K/5511K, external 24218K/24218K, paused 28ms
04-22 21:57:10.613: E/dalvikvm-heap(9570): 5891496-byte external allocation too large for this process.
04-22 21:57:10.613: E/dalvikvm(9570): Out of memory: Heap Size=5511KB, Allocated=3097KB, Bitmap Size=24218KB, Limit=32768KB
04-22 21:57:10.613: E/dalvikvm(9570): Trim info: Footprint=5511KB, Allowed Footprint=5511KB, Trimmed=448KB
04-22 21:57:10.613: E/GraphicsJNI(9570): VM won't let us allocate 5891496 bytes
这是我发送值时的代码:result.java
public class result extends Activity {
public static String destination = "";
搜索.java
public void setButtonClickListener() {
Button searchButton = (Button)findViewById(R.id.buttonSearch);
searchButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
result.destination = textView.getText().toString();
TabHost tabHost = (TabHost) getParent().findViewById(android.R.id.tabhost);
tabHost.setCurrentTab(0);
}
});
}
我的应用程序正在使用具有三种不同活动的选项卡视图。我还使用 .jpg 作为背景,标签内有一个图像视图。我已经阅读了External allocation too large for this process in Android 的答案,但我并没有完全理解。有人能以更简单的方式告诉我如何处理吗?或者我应该在哪里寻找答案?
对于发送值内存问题,我认为可能的问题在于标签之间的移动,因为当我继续在标签之间移动时,也会出现相同的错误。