RenderInContext / Memory problem

I have a problem. When I use "renderInContext" on the iPad, the used memory is never released or accumulated until the application closes with "Memory Warning" Level = 1 and Level = 2

My code is:

CGRect mediaBox = CGRectMake(0, 0, 16.54 * 72.0, 24.02 * 72.0); CGContextRef ctx = CGPDFContextCreateWithURL((CFURLRef)[NSURL fileURLWithPath:posterPath isDirectory:NO], &mediaBox, NULL); CGPDFContextBeginPage(ctx, NULL); CGContextScaleCTM(ctx, 0.516, -0.516); CGContextTranslateCTM(ctx, 0, -mediaBox.size.height - 1500); [[self returnBigView].layer renderInContext:ctx]; CGPDFContextEndPage(ctx); CGPDFContextClose(ctx); CGContextRelease(ctx); 

I tried several ways, but without free memory. Any ideas?

** Sorry for my bad english

+4
source share
2 answers

I had the same problem inside the loop - setting the contents of the layer to nil worked for me:

Freeing renderInContext result in a loop

+2
source

I had the same problem. After a lengthy investigation, it seems that the memory was not released because the code did not run in the main thread. Therefore, do not execute renderInContext when you are not working on the main thread!

0
source

Source: https://habr.com/ru/post/1346006/


All Articles