On 8 October 2011 07:39, Shiv Shankar Dayal wrote: > > We will have to have some function like alloca() which will allocate > memory on stack but this piece of > memory must not be released when SP goes down the stack. A record of > all allocated objects by this > function has to be kept. Also, there will be gaps or fragmentation in > Stack because of this for which > we will have to move allocated area down almost in all cases and > sometimes up. It may depend upon the > specification.
It sounds like all you're proposing is using the stack for dynamic allocation instead of the heap, then adding a compacting garbage collector. It's easier to just use the heap and make sure you don't leak memory. It's not that hard.