iPad崩溃和可能相关的内存问题

I am porting PC game to iPad which has ton of graphic assets (over 250MB) and I am about half-way through. I didn't have iPad until now so I tested it only on simulator and everything was fine. But when I run it on device for first time, it crashed. All I got from console is

Program received signal:  “0”.

Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")

there is also warning at the startup which I didn't have on simulator and I don't know what it means or if it is related:

warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2/Symbols/System/Library/AccessibilityBundles/AccessibilitySettingsLoader.bundle/AccessibilitySettingsLoader" (file not found).

I was able to determine that game crashes during loading of textures, most of the time at

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);

I use standard texture loading from samples and it worked perfectly so far. I estimate that at the time of crash I allocated few dozens mb worth of textures (I can't give you exact number right now).

I am no expert on anything, but it kinda seems like I run out of memory even though I don't get any memory warning (I check for them). Is it possible that I allocate more memory than I can at once and it crashes before it can issue memory warning? What surprises me most is that it doesn't throw exception or anything, it just dies on me. Even debugger doesn't tell me anything.

Any other ideas what can cause this crash?

And one last thing, I know this has been asked countless times before, but no one seems to have good answer to that. I will try asking anyway :) How many MB of memory can I get for my app? Is there some guaranteed minimum or theoretical (but still reachable :) ) maximum? Is there any way how to ensure I will have enough memory?

Game has a lot of fancy art graphics and I even though I use caching and I release textures that are currently not used, there still will be few dozens of mb of textures needed at one time. Is something like that even possible? How pro games handle lots of data? Any article would be greatly appreciated.

#0

The current model of iPad only has 256 MB available total on the system, and running Instruments on my device right now shows that it only has ~70 MB of that free for use after everything else is taken into consideration. Therefore, "a few dozens of MBs" might be pushing it when it comes to textures, depending on how large "a few" is.

If you are loading massive amounts of textures in one operation that is not on a background thread, you will not receive memory warnings simply because you'll jam up the main thread and prevent your application from receiving those warnings. You could load textures a few at a time, either on a background thread or by letting the run loop go to completion between each smaller texture load, and see if you can catch memory warnings at some point in the loading process.

Apple has a "Best Practices for Working with Texture Data" section in the OpenGL ES Programming Guide that I suggest you read. It has several tips for minimizing texture data size, prime among them being the use of PowerVR Texture Compression to massively reduce their in-memory size.

#1

How many MB of memory can I get for my app? Is there some guaranteed minimum or theoretical (but still reachable :) ) maximum?

You can have 500 megs of free memory, but it may be unavailable due to fragmentation (program XYZ may have taken a space between 255 and 284 MB, for example). Since that, there is a question of memory, that is available for each malloc() called.

Nowadays it's a rare situation (kernel and garbage collectors are smart enough), but still - "out of memory" is "cannot load shared library *.dylib: cant find free space segment longing for N mbs".

#2

Are you checking all your memory allocations and array bounds before any writes/loads?

推荐文章

反射actionscript对象

反射actionscript对象

推荐文章

可配置产品eshop的数据库设计建议

可配置产品eshop的数据库设计建议

推荐文章

如何使用正则表达式将字符串拆分为数字和字母

如何使用正则表达式将字符串拆分为数字和字母

推荐文章

运行使用A/CLR构建DLL的本机C++应用程序时的访问冲突

运行使用A/CLR构建DLL的本机C++应用程序时的访问冲突

推荐文章

访问控制列表基础知识

访问控制列表基础知识

推荐文章

如何在Visual Studio 2010加载项的菜单中添加文本框?

如何在Visual Studio 2010加载项的菜单中添加文本框?

推荐文章

有没有更简单的方法将字节数组转换为2字节大小的十六进制字符串?

有没有更简单的方法将字节数组转换为2字节大小的十六进制字符串?

推荐文章

在Tomcat中运行web应用get之前,我可以编写一个被触发的模块/过滤器吗?

在Tomcat中运行web应用get之前,我可以编写一个被触发的模块/过滤器吗?

推荐文章

使用IE8时出现artsexylightbox问题

使用IE8时出现artsexylightbox问题

推荐文章

从jCarousel插件中移除项

从jCarousel插件中移除项

推荐文章

对jQuery(和ASP.NET MVC)使用隐藏值——不起作用?

对jQuery(和ASP.NET MVC)使用隐藏值——不起作用?

推荐文章

iphone xcode-在选项卡栏controller-nav controller-table视图中进行不同级别的深入研究

iphone xcode-在选项卡栏controller-nav controller-table视图中进行不同级别的深入研究

推荐文章

在Android首选项中使用图标

在Android首选项中使用图标

推荐文章

如何在共享主机上安装python的boto库?

如何在共享主机上安装python的boto库?

推荐文章

如何有条件地从两个表中选择一个字段?

如何有条件地从两个表中选择一个字段?

推荐文章

有人能帮我在c语言中使用IList吗#

有人能帮我在c语言中使用IList吗#