堆栈被@autoreleasepool破坏(ARC,使用llvm 3.0编译,Fastest,Smallest [
一个加载图像并记录其大小的小程序。 它是用ARC支持,llvm 3.0编译的。 我在iPod 4.2上运行它,并得到一些有趣的数字...该程序以“发布”模式编译为“-Os”(xcode中“发布”的默认优化)。 整个事情不会发生在模拟器中。 它看起来像@autoreleasepool结合循环腐败堆栈...注意,我必须用这个简单的例子来隔离这个帖子的问题。
--------->
int main(int argc, char *argv[])
{
@autoreleasepool
{
return UIApplicationMain(argc, argv, nil,
@"AppDelegate");
}
}
@interface AppDelegate : UIWindow <UIApplicationDelegate>
@end
@implementation AppDelegate
-(void)loadImageAndLogValues
{
// image from bundle 256x26
UIImage *image = [UIImage imageNamed:@"Image.png"];
for (int i = 0; i < 1; i++)
{
NSLog(@"size=%@", NSStringFromCGSize(image.size));
NSLog(@"w=%f", image.size.width);
NSLog(@"h=%f", image.size.height);
NSLog(@"------------------------");
}
}
-(BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.frame = [UIScreen mainScreen].bounds;
self.backgroundColor = [UIColor blueColor];
[self makeKeyAndVisible];
[self loadImageAndLogValues];
UIGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(loadImageAndLogValues)];
[self addGestureRecognizer:tap];
return YES;
}
@end
<------------------
这是我点击屏幕后的输出(“h”在拍摄后记录为“错误!”,图像的高度为26 ...):
2011-10-21 01:54:48.677 Tmp[2522:307] size={256, 26}
2011-10-21 01:54:48.696 Tmp[2522:307] w=256.000000
2011-10-21 01:54:48.705 Tmp[2522:307] h=26.000000
2011-10-21 01:54:48.715 Tmp[2522:307] ------------------------
2011-10-21 01:54:50.576 Tmp[2522:307] size={256, 26}
2011-10-21 01:54:50.582 Tmp[2522:307] w=256.000000
2011-10-21 01:54:50.589 Tmp[2522:307] h=256.000000
2011-10-21 01:54:50.595 Tmp[2522:307] ------------------------
现在,我从main()中删除@autoreleasepool:
int main(int argc, char *argv[])
{
//@autoreleasepool
//{
return UIApplicationMain(argc, argv, nil,
@"AppDelegate");
//}
}
运行该程序并点击。 仍然错误的值为“h”,但直接从“application:didFinishLaunchingWithOptions:”调用“loadImageAndLogValues”...
2011-10-21 02:02:08.222 Tmp[2544:307] size={256, 26}
2011-10-21 02:02:08.240 Tmp[2544:307] w=256.000000
2011-10-21 02:02:08.250 Tmp[2544:307] h=256.000000
2011-10-21 02:02:08.259 Tmp[2544:307] ------------------------
2011-10-21 02:04:59.097 Tmp[2544:307] size={256, 26}
2011-10-21 02:04:59.103 Tmp[2544:307] w=256.000000
2011-10-21 02:04:59.109 Tmp[2544:307] h=26.000000
2011-10-21 02:04:59.115 Tmp[2544:307] ------------------------
所以?... ARC + llvm 3.0 + -Os + @autoreleasepool + for(;;)+ image.size.width / height不适合我:)请帮忙! 谢谢!
(顺便说一句)阅读LLVM与GCC的iOS开发设法解决了这个问题...... ARMv6正是为我的iPod而烦恼。 “修复”是仅对ARMv6配置禁用拇指支持。 很好,但很奇怪...
链接地址: http://www.djcxy.com/p/72749.html上一篇: Stack corrupted with @autoreleasepool (ARC, compiled with llvm 3.0, Fastest, Smallest [