Hey, I am having some trouble finding out how to free ram on the iPhone using Xcode and the iOS SDK. If anyone could give me a hand doing this that would be great.
Thanks in advanced.
Hey, I am having some trouble finding out how to free ram on the iPhone using Xcode and the iOS SDK. If anyone could give me a hand doing this that would be great.
Thanks in advanced.
Generally one implements behaviour to free things like cached data, in the -didReceiveMemoryWarning
method. Then, when the OS sends a memory warning to your application, that method will be called.
If this is for your own use (not for the App store), and you wish to push other apps out of memory, then use a repeating NSTimer to continue to try and allocate (malloc) large and random page sized memory blocks, say 30 times a second for several seconds, and/or until you can't allocate any more, all the while mostly ignoring memory warnings.
Then free all these allocations at once... if your app is the one left running by the OS.