Memory leak problem. iPhone SDK

Posted by user326375 on Stack Overflow See other posts from Stack Overflow or by user326375
Published on 2010-04-26T21:48:54Z Indexed on 2010/04/26 21:53 UTC
Read the original article Hit count: 416

Filed under:
|
|
|
|

Hello, i've got a problem, i cannot solve it, just recieving error:

Program received signal: “0”.

The Debugger has exited due to signal 10 (SIGBUS).The Debugger has exited due to signal 10 (SIGBUS).

Here is some method, if i comment it out, problem goes aways

- (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);
     }
 }

anyone can help me with releasing/deleting objects in this method? Thanks.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about SDK