English 中文(简体)
CGDataprovider ,t 免除有关退约的数据
原标题:CGDataProvider doesn t free up data on callback

我正在使用《刑法》中“CGDataProviderRef”建立一个非常大的缓冲(所谓的缓冲2):

-(UIImage *) glToUIImage {
NSInteger myDataLength = 768 * 1024 * 4;
// allocate array and read pixels into it.
GLubyte *buffer = (GLubyte *) malloc(myDataLength);
glReadPixels(0, 0, 768, 1024, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

// gl renders "upside down" so swap top to bottom into new array.
// there s gotta be a better way, but this works.
GLubyte *buffer2 = (GLubyte *) malloc(myDataLength);
for(int y = 0; y <1024; y++)
{
        for(int x = 0; x <768 * 4; x++)
        {
                buffer2[(1023 - y) * 768 * 4 + x] = buffer[y * 4 * 768 + x];
        iii
iii

 // make data provider with data.
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer2, myDataLength, &releaseBufferData);

// prep the ingredients
int bitsPerComponent = 8;
int bitsPerPixel = 32;
int bytesPerRow = 4 * 768;
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;

// make the cgimage
CGImageRef imageRef = CGImageCreate(768, 1024, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);

// then make the uiimage from that
UIImage *myImage = [UIImage imageWithCGImage:imageRef];

free(buffer);
//[provider autorelease];
CGDataProviderRelease(provider);
CGColorSpaceRelease(colorSpaceRef);
CGImageRelease(imageRef);

return myImage;

iii

我期望,在使用缓冲2时,卡多维卡提供商将释放BufferData方法击退,以便我能腾出的记忆。 这种方法的代码是:

static void releaseBufferData (void *info, const void *data, size_t size){  
 free(data);  
iii

然而,尽管我采用背信弃义的方法,但人们从未听说过数据(图2)。 我做了什么错误?

最佳回答

出于某些特殊原因,这不是一个问题。

问题回答

您是否在<条码>上签字? 如果你不释放数据提供者,不会打退。

就在这样的情况下,这帮助了其他人。 我也存在同样的问题。 一旦我叫我,它就开始工作。

CGImageRelease(imageRef);

目 录

CGDataProviderRelease(provider);

在“释放”呼吁中,当它分配到一线时,就释放了,但处理其位置的回击却在另一边执行。 • 满足你们的分配和分配:

dispatch_async(dispatch_get_main_queue(), ^{
 // *malloc* and *free* go here; don t call &releaseCallBack or some such anywhere 
});

第二项尝试是完成。 不是以传统方式(通过归还财产的方法)归还形象,而是使用完成制。 完成区一旦关闭,UIImage将被释放。

例如,如果你重新设法将多幅图像保存到照片图书馆,但每张图像形成后,小孔径线数据便排出,然后通过一个完成栏,确保你不会再造新的图像,一旦它打上<代码>};,就会很快。

第三点是电离层,而不是小层:

GLubyte *buffer = (GLubyte)*

现在我曾经感到迷惑不解的是,这排除了以前两项建议的必要性。 我使用开放式广播公司,用单一囚室一行,每个囚室有一个录像带。 为了播放录像,如果你看到你想要挽救的形象,你就会动摇收集的观点;如果你想在录像中推进这一框架,你会把这个内容加以利用。 如你所知,即便是短视的视频也有许多框架;电离辨率解决方案 k点,大约256兆米,总记忆使用量,每打听一次排放回击,当你挥发bl时,便会架起。





相关问题
Windows Mobile 6 Emulator change storage?

How do i change the size of the Windows Mobile 6 Emulator. Its fixed at 32mb. I read this post: Increasing Windows Mobile 5 Emulator Storage But it only helps for the 5.0 version. Isnt there any way ...

CUDA Memory Allocation accessible for both host and device

I m trying to figure out a way to allocate a block of memory that is accessible by both the host (CPU) and device (GPU). Other than using cudaHostAlloc() function to allocate page-locked memory that ...

RAM memory reallocation - Windows and Linux

I am working on a project involving optimizing energy consumption within a system. Part of that project consists in allocating RAM memory based on locality, that is allocating memory segments for a ...

Should I send retain or autorelease before returning objects?

I thought I was doing the right thing here but I get several warnings from the Build and Analyze so now I m not so sure. My assumption is (a) that an object I get from a function (dateFromComponents: ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

doubts regarding Memory management in .net

I m learning about Memory management in C# from the book "Professional C#" The presence of the garbage collector means that you will usually not worry about objects that you no longer need; ...

Objective-C returning alloc d memory in a function == bad?

This is on the iPhone. So what if I have a function like - (SomeObject*)buildObject; Do I need to pass in a variable that I have already alloc d outside like - (void)assignObject(SomeObject** out);...

热门标签