stack and heap issue for iPhone memory management
- by Forrest
From this post I got know that
the Objective-C runtime does not allow
objects to be instantiated on the
stack, but only on the heap; this
means that you don’t have “automatic
objects”, nor things like auto_ptr
objects to help you manage memory;
Someone give one example in post Objective C: Memory Allocation on stack vs. heap
NSString* str = @"hello";
but this NSString is also not allocated in stack. Feel odd that this str is static. (Who can explain this ? )
Question here is that why there is no heap ? even mixing c++ together with Object C ?
/////////////////////////////// Clear my question ///////////////////////////////
I am confused , so questions are not clear. Let me put in this way.
1) All Object C objects should be
alloc in stack ? ( I think yes )
2)In C++, there are stack for memory,
so for iOS app, also have stack ? ( I
think yes )
3) for iOS app, if only
use Object C, so what is the usage of
stack ? what kind of objects should
use stack then ?