tags:

views:

55

answers:

3

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

+1  A: 

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

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

Paul Hankin
+3  A: 

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).

paxdiablo
I think it helps to think of it as releasing objects rather than memory. The actual memory gets deallocated by the runtime which sends a dealloc message to the object when the retain count becomes zero.
Plumenator
+1 for madness. Learn to grok lifetime of your allocations or go insane. There's not much middle ground available....
RBerteig
+1  A: 

Read Memory Management Programming Guide.

stefanB