Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Basically you should release your references, especially the CGImageRef since the imageWithCGImage doesn't take ownership of the CGImage but rather seems to copy the data internally.</p> <p>The docs on this are quite unclear, but from what I have found in my testing if I don't release CGImageRefs and CGDataProviderRefs it will eventually cause the application to get memory warnings... and then crash.</p> <p>Not sure why you would have a crash, but in doing a quick test with:</p> <pre><code>UIImageView *view = [[UIImageView alloc] init]; int I = 128; unsigned char *topologyImage = malloc(I*I*4*sizeof(unsigned char)); for(int i=0; i&lt;I*I*4; i++) { topologyImage[i] = 100; } for(int i=0; i&lt;1000; i++) { CGColorSpaceRef colorSpaceRef=CGColorSpaceCreateDeviceRGB(); CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault | kCGImageAlphaLast; CGColorRenderingIntent renderingIntent=kCGRenderingIntentDefault; CGDataProviderRef provider=CGDataProviderCreateWithData(NULL,topologyImage,(I*I*4),NULL); CGImageRef imageRef=CGImageCreate(I,I,8,4*8,4*I,colorSpaceRef,bitmapInfo,provider,NULL,false,renderingIntent); CGColorSpaceRelease(colorSpaceRef); CGDataProviderRelease(provider); UIImage *img=[UIImage imageWithCGImage:imageRef]; view.image = img; CGImageRelease(imageRef); } free(topologyimage); </code></pre> <p>Seems to work just fine for me, so whatever is causing your crash seems to be because of something outside of your example, like for example how you got the image data into the topologyImage</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload