Objective C: Memory Allocation on stack vs. heap -


i confused when things allocated on heap (and need release them) , when allocated on stack (and don't need relese them).

is there rule of thumb?

i think in c++ rule of thumb if use new keyword on heap. rule objective c? how can tell when allocated on stack?

will line of code allocated on stack?

nsstring *user = @"default"; 

in objective-c, it's easy: objects allocated on heap.

the rule is, if call method alloc or new or copy in name (or call retain), own object, , must release @ point later when done it. there has been plenty written on subject.

the example give special case: that's static string, believe located in program's data segment (on heap), it's static don't need worry releasing it.


Comments

Popular posts from this blog

400 Bad Request on Apache/PHP AddHandler wrapper -

Add email recipient to all new Trac tickets -

php - Change action and image src url's with jQuery -