如何显示iPhone的可用内存?以及如何释放iPhone内存? [英] How to display iPhone free memory ? and how to free iPhone memory?

查看:132
本文介绍了如何显示iPhone的可用内存?以及如何释放iPhone内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在UILabel中显示iPhone的可用内存?

How to display iPhone free memory in a UILabel ?

我想问一下,如何使用iPhone SDK释放内存?

and I would like to ask, how to free up memory using iPhone SDK?

仅供参考,我正在将iPhone SDK 3.1.2与xcode 3.2.1(Mac OS X Snow Leopard)结合使用.

FYI, I'm using iPhone SDK 3.1.2 with xcode 3.2.1 (Mac OS X Snow Leopard).

推荐答案

SDK中无法直接访问此信息,并且不允许应用按照您的建议来弄乱操作系统.你在自己的小盒子里;苹果希望您留在那里.当您问包括系统"在内的问题时,您可能不在您的讨论范围之内.

There is no direct access to this information in the SDK, and apps are not allowed to mess around with the OS the way you're suggesting. You're in your own little box; Apple expects you to stay there. When you ask questions that include "the system," you are probably outside of your box.

也就是说,您可以使用一些技巧.您可以分配越来越大的内存块,直到收到-didReceiveMemoryWarning.此时,释放您分配的内存.这将使您大致了解操作系统允许拥有多少内存.当然,这与操作系统的数量是不一样的.触发-didReceiveMemoryWarning还将导致操作系统自行执行一些内务处理,因此,这几乎是您必须释放内存的最有效的编程方式.

That said, there are some tricks you can use. You can allocate increasingly-large blocks of memory until you receive -didReceiveMemoryWarning. At that point, release your allocated memory. That will give you a rough idea of how much memory the OS will allow you to have. That's not the same as how much the OS has of course. Tripping -didReceiveMemoryWarning will also cause the OS to do some housekeeping of its own, so this is pretty much the most effective programmatic way you have to free up memory.

释放内存的最有效的非编程方式是要求用户重新启动.对于需要大量内存的应用程序(通常是游戏),这种方法并非闻所未闻.

The most effective non-programmatic way to free up memory is to ask the user to reboot. For applications that require substantial memory (generally games), this approach is not unheard of.

SBSettings需要越狱,并且在SDK之外.

SBSettings requires jailbreaking and is outside of the SDK.

这篇关于如何显示iPhone的可用内存?以及如何释放iPhone内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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