How to display iPhone free memory ? and how to free iPhone memory?

烂漫一生 提交于 2019-12-05 19:31:25

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.

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 requires jailbreaking and is outside of the SDK.

Josh Knauer

It is possible to determine the amount of free memory on an iPhone using the mach api. See this related question: Available memory for iPhone OS app

You can free up memory by calling "release" on objects you've allocated after you're done with them. See http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!