How to display iPhone free memory in a UILabel ?
and I would like to ask, how to free up memory using iPhone SDK?
FYI, I'm using iPhone SDK 3.1.2 with xcode 3.2.1 (Mac OS X Snow Leopard).
How to display iPhone free memory in a UILabel ?
and I would like to ask, how to free up memory using iPhone SDK?
FYI, I'm using iPhone SDK 3.1.2 with xcode 3.2.1 (Mac OS X Snow Leopard).
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
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.
It is possible to determine the amount of free memory on an iPhone using the mach api. See this related question: http://stackoverflow.com/questions/2798638/available-memory-for-iphone-os-app