iphone项目 浏览100张卡片 老是crash

返程Open 2012-03-02 05:12:00
iphone项目 浏览100张卡片 老是crash 为什么啊 是内存不够吗?大侠们 帮帮我
...全文
173 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
咸清 2012-03-06
  • 打赏
  • 举报
回复
iOS动态开辟空间建议不超过20M,提倡打包为资源文件随用随取。
相关代码参考 电子书 。
返程Open 2012-03-06
  • 打赏
  • 举报
回复
但是如何限制 只加载三张呢 谢谢 [Quote=引用 10 楼 jiangyuaiqing 的回复:]

我们加载图片的时候一般都是只显示当前页的。或者当前页,前一页,和后一页三张。其他的后续加载。
[/Quote]

Snake_Jay 2012-03-06
  • 打赏
  • 举报
回复
我们加载图片的时候一般都是只显示当前页的。或者当前页,前一页,和后一页三张。其他的后续加载。
咸清 2012-03-06
  • 打赏
  • 举报
回复
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug


说的多清楚啊……
返程Open 2012-03-06
  • 打赏
  • 举报
回复
恩 你好 我的项目是100张卡片 我要来回浏览 如果刚开始等等 的话 快速浏览页面就不会crash 如果一开始进入程序就狂拉页面 拉到后面就老是容易crash。。这个怎么弄啊 。。。还有你说根据页面显示的张数加载 我的页面会显示5张 中间大的 两边前后各两个缩小放在边上 这个怎么弄呀?、谢谢啦
newlcc 2012-03-06
  • 打赏
  • 举报
回复
不要同时把100张照片都加载,应该根据界面显示的张数来加载。
返程Open 2012-03-06
  • 打赏
  • 举报
回复
[code=C/C++][/code- (void)setCards:(NSMutableArray *)value {
_cards = value;
UIImage * imgDefault = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]];
for(int i = 0;i<[_cards count];i++){
Card *card = [_cards objectAtIndex:i];
NSArray *temp = [card.front componentsSeparatedByString:@"."];
GLuint defaultTexture = [self imageToTexture:imgDefault];
GLuint texture1;
if ([card.front isEqualToString:@"Default.png"]) {
texture1 = defaultTexture;
}
else {
UIImage *img = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[temp objectAtIndex:0] ofType:[temp objectAtIndex:1]]];
texture1 = [self imageToTexture:img];
[img release];
}
FlowCoverRecord *fcr = [[FlowCoverRecord alloc] initWithTexture:texture1];
NSNumber *num = [NSNumber numberWithInt:i];
[cache setObject:fcr forKey:num];
[fcr release];
}
[imgDefault release];
[self performSelectorInBackground:@selector(loadOtherCards) withObject:nil];
}

/*
* Load Other cards
*/
- (void)loadOtherCards{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
//Load other cards
NSLog(@"load othercards");
//A flag used to judge whether other card is loaded.
BOOL flag = NO;

Card * defaultCard = [_cards objectAtIndex:[_cards count]-1];
if ([defaultCard.front isEqualToString:@"Default.png"]){
flag = YES;
for (int i =3; i < [_cards count]; i++) {

Card *card = [[Card alloc] init];
card.cardID = i;

if(i<9){
card.front = [NSString stringWithFormat:@"%@0%d.png",CARDFRONT_PREFIX,i+1];
card.back = [NSString stringWithFormat:@"%@0%d.png",CARDBACK_PREFIX,i+1];
}else{
card.front = [NSString stringWithFormat:@"%@%d.png",CARDFRONT_PREFIX,i+1];
card.back = [NSString stringWithFormat:@"%@%d.png",CARDBACK_PREFIX,i+1];
}
NSLog(@"card front : %@",card.front);
[_cards replaceObjectAtIndex:i withObject:card];

//If the other cards loading has not been fiinshed,then load and setCards.
if (flag) {
NSArray *temp = [card.front componentsSeparatedByString:@"."];
GLuint texture;
UIImage *img = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[temp objectAtIndex:0] ofType:[temp objectAtIndex:1]]];
NSLog(@"111111111111");
texture = [self imageToTexture:img];
NSLog(@"2222222222222");
[img release];
FlowCoverRecord *fcr = [[FlowCoverRecord alloc] initWithTexture:texture];
NSNumber *num = [NSNumber numberWithInt:i];
[cache setObject:fcr forKey:num];
[fcr release];
int maxVisibleCount = floor(offset + 0.5) + VISTILES;
if (i <= maxVisibleCount ) {
[self performSelectorOnMainThread:@selector(draw) withObject:nil waitUntilDone:YES];
}
}
[card release];
}
}
else {
flag = NO;
}

[pool release];
}
返程Open 2012-03-06
  • 打赏
  • 举报
回复
unable to read unknown load command 0x26
warning: UUID mismatch detected with the loaded library - on disk is:
/Developer/Platforms/iPhoneOS.platform/DeviceSupport/5.0.1 (9A405)/Symbols/System/Library/Extensions/IMGSGX535GLDriver.bundle/IMGSGX535GLDriver
unable to read unknown load command 0x25
unable to read unknown load command 0x26
gdb-arm-apple-darwin(1358,0xa0483540) malloc: *** mmap(size=24268800) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
gdb stack crawl at point of internal error:

/SourceCache/gdb/gdb-1510/src/gdb/utils.c:1200: internal-error: virtual memory exhausted: can't allocate 24267986 bytes.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

The Debugger has exited with status 1.The Debugger has exited with status 1.
返程Open 2012-03-06
  • 打赏
  • 举报
回复
有人吗?
相奇 2012-03-06
  • 打赏
  • 举报
回复
用线程 加载控制数据。一次5个就好了
princebanana 2012-03-06
  • 打赏
  • 举报
回复
不要一次将图片全部加到内存去,需要时加载
_0筱筱0_ 2012-03-05
  • 打赏
  • 举报
回复
你是在真机上还是在虚拟机上?加载的方式是什么?
Snake_Jay 2012-03-05
  • 打赏
  • 举报
回复
怎么个浏览法?贴个consol上吧,可能是内存不够导致的crash。
longlongago2000 2012-03-04
  • 打赏
  • 举报
回复
贴上crash异常信息看看才知道

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧