如何在ARC中释放内存以获得高内存使用率的图形渲染? [英] How to free memory in ARC for high memory usage graphics render?

查看:120
本文介绍了如何在ARC中释放内存以获得高内存使用率的图形渲染?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,感谢本网站上的所有人......对于深入了解iOS编程,这一点非常有帮助。

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

我当前的问题:

我有一个应用程序,可以呈现一个非常风格化的照片版本。它为其中一些使用了一些CoreImage过滤器,但需要一堆CoreGraphics来完成繁重的图像处理。

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.

代理大小渲染效果很好,但是当我渲染我的图像的完整分辨率版本时,由于内存使用率很高,它有时会崩溃。问题是我需要能够在渲染时在内存中有几个全分辨率(3264x2448)缓冲区。我不知道什么或如何释放更多的记忆。我一直非常小心地匹配CGImageRelease到处都可以。

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.

使用ARC,我如何知道某些内容是否真正被释放并释放?将对象设置为nil并没有真正做任何事情。

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.

非常感谢任何建议!

感谢!

推荐答案

ARC在这样的背景下没有什么区别。

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

这只是意味着你不必打电话给发布由你自己。

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

对于非ARC,在内存不足的情况下,你可能想要发布一些你并不真正需要的属性(意思是它们可以按需重新创建。)

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 ];
}

在ARC下,它完全一样,除了你不必打电话 release

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

- ( void )didReceiveMemoryWarning:
{
    _myProperty = nil;

    [ super didReceiveMemoryWarning ];
}

将您的房产设置为 nil
所以它确实有所作为。

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...

这篇关于如何在ARC中释放内存以获得高内存使用率的图形渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆