Android: failed to allocate memory(Android:分配内存失败)
问题描述
我正在尝试创建一个具有 2047 mb 内存的模拟器.当我运行它时,我得到了这个错误:
[2011-02-22 14:24:14 - 模拟器][2011-02-22 14:24:14 - Emulator] 此应用程序已请求运行时以不寻常的方式终止它.[2011-02-22 14:24:14 - Emulator] 请联系应用程序的支持团队以获取更多信息.[2011-02-22 14:24:26 - 模拟器] 分配内存失败:8
我知道降低数字会使它起作用.但我宁愿拥有更多的内存,这样我就可以测试我正在开发的游戏.我假设有更多的内存,它会运行得更快......
有人在模拟器上安装了 2047 mb 的内存吗?如果是这样,怎么做?您使用了哪些设置?您是否更改了计算机上的任何特别内容?
使用windows 7 64位,更新到最新的android sdk.我还有超过 8gb 的可用内存.我确实有一个设备(摩托罗拉里程碑)可以测试,但是由于它是一个基于网络的游戏,除了我的手机之外,我还需要至少一个其他客户端(希望使用模拟器)来运行.
运行更快的模拟器的解决方案:
http://androiddevnotes.com/2011/03/08/1299521520000.htmlp>
让我的游戏运行速度更快,堪比手机质量.
-- 2012 年 8 月 24 日更新--
我看到仍然有人来这里评论这个答案,我对这个问题做了更多的研究.我向您介绍我的发现结果.
注意:这些测试是在我的电脑上运行的,您的电脑可能不同.
- 使用属性设备内存大小"= 2048 运行 Android 2.2 (armeabi) 模拟器将失败,和以前一样
- 运行一个 Android 2.2 (armeabi) 模拟器,属性 'Device ram size' = 2048 MB 会通过,然而如果你真的检查设备上的 ram,它的大约 128 MB.
- 检查 1:设置 > 应用程序 > 运行服务 - 在屏幕底部添加所有数字
- 检查 2:在 adb shell 中运行以下命令:
cat/proc/meminfo/
并注意 MemTotal 字段
- 使用属性设备内存大小"= 2048 运行 Android 4.1 (armeabi-v7) 模拟器将可以工作,但是如果您实际检查设备上的内存,它大约为 512 MB
- 检查 1:设置 > 应用程序 > 运行选项卡 - 在屏幕底部添加所有数字
- 检查 2:在 adb shell 中运行以下命令:
cat/proc/meminfo/
并注意 MemTotal 字段
- 运行一个 Android 4.1 (armeabi-v7) 模拟器,属性 'Device ram size' = 2048 MB 也可以,但结果与 3 相同.
结论
添加 'MB'(如下面的一些评论中所述)可能会允许您的设备启动,但它实际上没有 2 GB 的 RAM.即使使用 4.1 模拟器,RAM 大小也为 512 MB.
推荐
请使用实际设备进行测试.
I'm trying to create an emulator with 2047 mb ram. When I run it, I get this error:
[2011-02-22 14:24:14 - Emulator]
[2011-02-22 14:24:14 - Emulator] This application has requested the Runtime to terminate it in an unusual way.
[2011-02-22 14:24:14 - Emulator] Please contact the application's support team for more information.
[2011-02-22 14:24:26 - Emulator] Failed to allocate memory: 8
I understand that lowering the number will make it work. But I'd rather have it with more ram, so I can test a game I'm developing. I'm assuming with more ram, it would run faster...
Has anyone got 2047 mb of ram on the emulator? If so, how? What settings did you use? Did you change anything special on your computer?
Using windows 7 64-bit, updated to the latest android sdk. Also I have over 8gb of ram available. I do have one device (motorola milestone) to test on, however since it is a network-based game I need at least one other client (hoping to use the emulator) to run with in addition to my phone.
Solution to running a faster emulator:
http://androiddevnotes.com/2011/03/08/1299521520000.html
Runs my game a lot faster, comparable to phone quality.
-- Update 08/24/12 --
I see that people still come here and comment on this answer, and I have done more research on this issue. I present to you the results of my findings.
NOTE: These tests were run on my computer, your computer may be different.
- Running an Android 2.2 (armeabi) emulator with Property 'Device ram size' = 2048 will fail, just as before
- Running an Android 2.2 (armeabi) emulator with Property 'Device ram size' = 2048 MB will pass, however if you actually check the ram on the device, its around 128 MB.
- check 1: Settings > Applications > Running Services - add all the numbers on the bottom of the screen
- check 2: run the following command in adb shell:
cat /proc/meminfo/
and note the MemTotal field
- Running an Android 4.1 (armeabi-v7) emulator with Property 'Device ram size' = 2048 will work, however if you actually check the ram on the device its around 512 MB
- check 1: Settings > Apps > Running tab - add all the numbers on the bottom of the screen
- check 2: run the following command in adb shell:
cat /proc/meminfo/
and note the MemTotal field
- Running an Android 4.1 (armeabi-v7) emulator with Property 'Device ram size' = 2048 MB will work as well, but with the same results as 3.
Conclusion
Adding 'MB' as noted in some of the comments below may allow your device to be launched, however it doesn't actually have 2 GB of RAM. Even with a 4.1 Emulator, the RAM Size is at 512 MB.
Recommendation
Please use an actual device for testing.
这篇关于Android:分配内存失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android:分配内存失败
基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01