(iphone)当乐器显示“所有分配”时,我的应用程序会收到内存警告只有7mb? [英] (iphone) my app gets memory warning when instruments shows "all allocations" only 7mb?

查看:129
本文介绍了(iphone)当乐器显示“所有分配”时,我的应用程序会收到内存警告只有7mb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如问题所说,它死于7mb ..

as question says, it dies at 7mb..

这是正常的吗? (7mb ..)

工具显示没有泄漏。

Is this normal? ( 7mb..)
instruments shows no leaks.

谢谢


  • 编辑

编辑17mb - > 7mb。
我通过取出我分配的不必要的池来降低内存使用量。

edited 17mb -> 7mb. I lowered memory usage by taking out unnecessary pool I was allocating.

尽管如此,它仍然会获得7 mb的内存警告..
我实际上是在创建图像并在收到警告时不断发布它们。

Still, it gets memory warning at 7 mb.. I'm essentially creating images and releasing them constantly when it gets the warning.

我做了很多

- (UIImage*) allocImage
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    UIImage* uiImage = [UIImage imageWithData: imageData];
    UIImage* changedImage = [uiImage changeColor: self.currentColor];
    uiImage = changedImage;
    [uiImage retain];
    [pool release];

    return uiImage;
}

并释放我得到的uiImage(乐器显示内存上升2-3 mb并返回到7mb)

and releasing the uiImage I got (instruments shows memory goes up by 2-3 mb and goes back to 7mb)

每个图像在内存上都是1mb大,到应用程序收到警告时我应该创建/销毁图像大约100次。

Each image is 1mb big on memory, and I should probably have create/destroyed image about 100 times by the time the app gets the warning.


  • 编辑2

发现类似案例,虽然没有解决方案..

found similar case, no solution there though..

我的iphone应用程序获得内存警告并以6.8MB杀死

内存警告但小活字节数

也许我应该将创建UIImage移动到c / c ++代码?这样我就不用担心加载很多图像了?不知道是否可能。

或者可能使用内存池来处理图像,因为图像大小都是一样的。

Maybe I should move "creating UIImage" to c/c++ code? so that I don't have to worry about loading many images? Wonder if that's possible.
Or maybe use pool of memory for images since image size is all the same.

推荐答案

这取决于很多因素,有问题的设备,iOS版本,设备上发生的其他事情同时,等等。基本上,你应该在他们到达时认真对待警告。获得警告不是问题。当你得到它们时什么也不做是个坏主意。

It depends on a lot of factors, the device in question, the iOS version, what else is happening on the device at the same time, etc. Basically, you should take the warnings seriously whenever they arrive. Getting the warnings is not a problem. Doing nothing when you get them is a bad idea.

根据我的经验,17Mb处于正常的低端。

In my experience, 17Mb is on the low side of normal.

这篇关于(iphone)当乐器显示“所有分配”时,我的应用程序会收到内存警告只有7mb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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