Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

[iphone sdk] memory allocations and application sandboxing

folks,

does the os automatically de-allocate any memory allocated when my app exists? reason i ask is the phone seems to get slower and slower over time with more crashes. a hard restart seems to fix the problem.

i'm guessing that it is because i'm not cleaning things up on exit or something, but maybe there is something else wrong.

john

mac book pro

Posted on Jun 29, 2008 11:03 AM

Reply
4 replies

Jun 30, 2008 1:54 PM in response to johne-dm

The academic answer is: It shouldn't matter how much memory you leak in your app after the app has been closed. I can't speak to how the device functions cause I can't test on one yet! But it's UNIX under the hood and that means each process is assigned it's own address space. Any memory allocated to a process is completely reclaimed when the process exits.

I'm not sure what changes Apple made to the VM kernel subsystem for the iPhone. Unix is already tried and tested in this arena -- so if it's the default Darwin VM I would be very surprised if this is a bug. But since this is embedded they may have added some "shortcuts" for performance and efficiency... hard to say. Since you have the device, are you able to do any system level diagnostics? does the device lose free memory the more your start/stop your app?

Also -- the device has 128MB of RAM. The 8 or 16GB is storage, which isn't used for RAM. The specs are hard to find, but I think I found the answer through Google on the amount of RAM in the iPhone and iPod Touch.

Cheers,
George

Jun 30, 2008 3:17 PM in response to Steve Patt

I'm not sure about the 3G. But the iPod Touch and first gen iPhone both have 128MB of RAM.

As for loading large datasets, you are correct to worry about memory limitations. You'll likely have to load only immediately useful data. The SQLite Books example has a neat implementation of hydrate/dehydrate methods to read/store data to the backing store as needed in order to keep as much memory free as possible. And you'll also likely want to only load a certain number of records at a time, especially if the user has the ability to add records. You can't control how many records they will add and if they breach the memory limit, then your "load all on application start" will turn into a "my application will not run at all" 🙂. I'm dealing with this myself in my design.

[iphone sdk] memory allocations and application sandboxing

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.