erazorx
erazorx

Reputation: 2047

iPhone Memory Leaks

If an application produces a lot of memory leaks, are they "just" an in-app problem or are they also in RAM after the termination of the application? So does the iPhone OS release the memory allocated for the sandboxed application?

Thank you

Upvotes: 5

Views: 800

Answers (3)

cms
cms

Reputation: 5982

Memory leaks are blocks of memory allocated by the OS for your program to use while it is running, but not correctly returned as not in use when the program has finished with them. So this memory is 'lost'. Your program isn't using it, but the system doesn't yet know that it is free for other use.

When your application finishes running, all of the memory allocated to it by the OS, will be returned for re-use. Which answers your question.

However, memory leaks are a significant bug. On a low-memory device, like an iPhone, the less memory you consume the better, you don't want to be leaking memory as you run. If the device runs low on memory, your application may be terminated or crash, unexpectedly.

Upvotes: 16

Cyril Godefroy
Cyril Godefroy

Reputation: 1400

Memory leaks are an in-app problem, but can have side effects on the total available RAM.

They are blocks of memory that are marked in use when they actually are no more used. So they are lost to the app. If you have leaks, this will increase memory consuption. And bad memory usage will be noted by the system and the app might be jettisoned (killed) by the watchdog, jetsam.

So keep your memory leaks to a minimum ;-)

It has an effect on the overall OS, but negligible in consequences. Because your app is not killed when you tap the hole button, but rather "backgrounded", all the memory that's used by your app is still live and unavalaible to the system. Jetsam will first tell you that the memory is low and ask you to get rid of stuff you don't need. Of course you cannot free your leaks.

If you still use too much memory for the system, and it needs to allocate more memory for another process, your app will get killed. All the memory it used will be freed, leaks included.

Leaks are bad, use the static CLang analyzer in Build and analyze.

Upvotes: 1

Pavan
Pavan

Reputation: 443

Memory leaks occur when you allocate any object and miss out to release that objects while running application , so do analyse in xcode which will help in checking memory leaks, and run profile mode in xcode will help to check leaks possible in application.

and use NSAutoReleasePool to release the autorelease objects which will be created when you just assign objects wothout allocating

hope it helps .

Upvotes: 1

Related Questions