Richa Vijayvargiya
Richa Vijayvargiya

Reputation: 209

When should I release memory?

How do I decide when I should release memory? Because If I release the memory, many times the application crashes.

Upvotes: 1

Views: 138

Answers (3)

stefanB
stefanB

Reputation: 79930

Read Memory Management Programming Guide.

Upvotes: 1

paxdiablo
paxdiablo

Reputation: 882646

You should release memory when you've finished with it. Objects are reference counted so, as long as you retain and release (and everyone else does too), you should have no problems.

If you find you're crashing because you release the memory, then either you or someone else isn't following the rules.

In either case, find out who isn't following the rules, and fix it. Don't hold on to memory just to avoid crashes. That way lies madness (and lack of memory).

Upvotes: 3

user97370
user97370

Reputation:

Try the apple documentation on memory management in objective-c.

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/MemoryMgmt/MemoryMgmt.html

Upvotes: 1

Related Questions