【发布时间】:2010-04-26 21:48:54
【问题描述】:
我有一个问题,我无法解决它,只是收到错误:
节目接收信号:“0”。
由于信号 10 (SIGBUS),调试器已退出。由于信号 10 (SIGBUS),调试器已退出。
这里有一些方法,如果我把它注释掉,问题就会消失
- (void)loadTexture {
const int num_tex = 10;
glGenTextures(num_tex, &textures[0]);
//TEXTURE #1
textureImage[0] = [UIImage imageNamed:@"wonder.jpg"].CGImage;
//TEXTURE #2
textureImage[1] = [UIImage imageNamed:@"wonder.jpg"].CGImage;
//TEXTURE #3
textureImage[2] = [UIImage imageNamed:@"wall_eyes.jpg"].CGImage;
//TEXTURE #4
textureImage[3] = [UIImage imageNamed:@"wall.jpg"].CGImage;
//TEXTURE #5
textureImage[4] = [UIImage imageNamed:@"books.jpg"].CGImage;
//TEXTURE #6
textureImage[5] = [UIImage imageNamed:@"bush.jpg"].CGImage;
//TEXTURE #7
textureImage[6] = [UIImage imageNamed:@"mushroom.jpg"].CGImage;
//TEXTURE #8
textureImage[7] = [UIImage imageNamed:@"roots.jpg"].CGImage;
//TEXTURE #9
textureImage[8] = [UIImage imageNamed:@"roots.jpg"].CGImage;
//TEXTURE #10
textureImage[9] = [UIImage imageNamed:@"clean.jpg"].CGImage;
for(int i=0; i<num_tex; i++) {
NSInteger texWidth = CGImageGetWidth(textureImage[i]);
NSInteger texHeight = CGImageGetHeight(textureImage[i]);
GLubyte *textureData = (GLubyte *)malloc(texWidth * texHeight * 4);
CGContextRef textureContext = CGBitmapContextCreate(textureData,
texWidth, texHeight,
8, texWidth * 4,
CGImageGetColorSpace(textureImage[i]),
kCGImageAlphaPremultipliedLast);
CGContextDrawImage(textureContext, CGRectMake(0.0, 0.0, (float)texWidth, (float)texHeight), textureImage[i]);
CGContextRelease(textureContext);
glBindTexture(GL_TEXTURE_2D, textures[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
free(textureData);
}
}
任何人都可以帮助我在此方法中释放/删除对象吗?谢谢。
【问题讨论】:
-
逐步介绍该方法。错误发生在哪一行?
-
它发生在第三次重启游戏时,所以第三次(有时是第四次)iPhone 会关闭我的应用程序。感觉这里隐藏着巨大的内存泄漏
-
我没有看到任何内存泄漏。
-
您的意思是每 3 次或 4 次启动应用程序或每 3 或 4 次重新启动应用程序内的某些内容时发生这种情况?
-
重启app里面的东西,是scene,cocos2dscene。
标签: iphone sdk cocos2d-iphone signals sigbus