Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to free memory in ARC for high memory usage graphics render?

First off, thank you to everyone on this site...it's been INCREDIBLY helpful in getting into the grit of iOS programming.

My current issue:

I have an app that renders a very stylized version of a photo. It uses some CoreImage filters for some of it, but needs a bunch of CoreGraphics to get the heavy image processing done.

The proxy size renders work out great, but when I render a full resolution version of my image, it sometimes crashes because of high memory usage. The problem is that I need to be able to have several full resolution (3264x2448) buffers in memory when rendering. I don't know what or how to free up more memory. I've been very careful with matching CGImageRelease's everywhere I can.

And with ARC, how do I know if something's really been released and freed up? Setting an object to nil doesn't really do anything.

And I doubt I can stream this to disk in any way.

ANY suggestions would be extremely appreciated!

THANKS!

like image 981
pizzafilms Avatar asked Dec 28 '22 07:12

pizzafilms


1 Answers

ARC doesn't make a difference in such a context.

It just mean you don't have to call release by yourself.

With non-ARC, under low-memory conditions, you may want to release some properties, that you don't really need (meaning they can be re-created on demand).

- ( void )didReceiveMemoryWarning:
{
    [ _myProperty release ];

    _myProperty = nil;

    [ super didReceiveMemoryWarning ];
}

Under ARC, it's exactly the same, except you don't have to call release:

- ( void )didReceiveMemoryWarning:
{
    _myProperty = nil;

    [ super didReceiveMemoryWarning ];
}

Setting your property to nil will, under ARC, automatically release it.
So it really does something.

If it's doesn't work for you, then you definitively have another problem.
Make sure you don't have memory leaks, nor retain cycles.

The last one is certainly the problem...

like image 165
Macmade Avatar answered Jan 17 '23 15:01

Macmade