I was under the impression that alloc
in Objective-C (when we invoke [anyObject alloc]
is actually implementing C function malloc
and the memory getting allocated in heap, but could not find anywhere the answer for this.
Also, while searching for alloc
, I found alloca
which allocates memory in stack. If I am not wrong, alloc
allocates memory in heap to create objects.
So, what is the difference between alloc
and malloc
(and alloca
)? Can anyone please summarize?