cocoa - CGDataProvider doesn't free up data on callback -


I am creating a huge buffer (called buffer 2 in code) using CGDataProviderRef with the following code:

  - (UIImage *) glToUIImage {NSInteger myDataLength = 768 * 1024 * 4; // array allocated and read it in pixels GLUBE * buffer = (GLUBE *) MOLOK (MYDATA LANG); GlReadPixels (0, 0, 768, 1024, GL_RGBA, GL_UnSIGNED_BYTE, buffer); // GL renders "invert", so swap from top to bottom in the new array // there will be a better way, but it works GLUBE * buffer 2 = (GLUBE *) MOLOK (MYDATA LANG); (Int x = 0; x <768 * 4; x ++) {buffer 2 [(1023 - y) * 768 * 4 + x] = buffer for [y (int y = 0; y & lt; 1024; y ++) * 4 * 768 + x]; }} / / Data provider data created with CGDataProviderRef Provider = CGDataProviderCreateWithData (NULL, Buffer2, Maidata Lang, and Release BufferData); // content int int bits PierComponent = 8; Int bits per second = 32; Int Bitespoir = 4 * 768; CGColorSpaceRef ColorSpotcher = CGColorSpaceCreateDeviceRGB (); CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault; CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; // cgimage CGImageRef imageRef = CGImageCreate (768, 1024, bits, PierComponent, bitsPerPixel, Bytepar, Colorspace, BitMapInfo, Provider, Zero, No, Rendering Present); // then uiimage from UIImage * myImage = [UIImage imageWithCGImage: imageRef]; Free (buffer); // [Provider Autoriz]; CGDataProviderRelease (provider); CGColorSpaceRelease (colorSpaceRef); CGImageRelease (imageRef); My image return;  

}

I hope CGProvider will call the release buffer data method when it is done with buffer 2 so that I can release the memory taken . The code for this method is:

  Fixed zero release buffer data (zero * info, blank blank * data, size_ty size) {free (data); }  

However, even though my callback method is called, memory (data) (buffer 2) takes it never free and therefore it is generated in large scale memory leaks is. What am i doing wrong

Have you ever retrieved CGDTpr your provider ? If you do not release the data provider, the callback will not be called.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -