It occurs to me not to be confused in the definitions between dynamic memory allocation and heap based allocations. Dynamic memory allocations are typically heap based. Dynamic as in at run time could also mean allocated from static storage.
I have found static allocation to be extremely useful when trying to bootstrap a processor and OS. The problem with dynamic (heap)memory allocation is that so much of the system has to be already working in order for it to work.
Quote:
I have my own malloc/free code, in about 200 lines of C.
Sure this doesnt' seem like much, but it's still greater than none. That C code would typically have to be written in assembler for the '02. For a small app not having to worry about dynamically allocated stuff can be a boon.
Most data with the exception of blobs have fixed sizes. Fixed sized data records can be defined in most cases.
Dynamically allocated memory does have its uses just like recursion can be a useful tool sometimes. But it gets overused sometimes and can impact performance. In the typical 6502 app it seems to me that statically allocating memory might be preferred.
Whether memory is allocated dynamically (on heap) or not, can be hidden by the function call to allocate memory, so that the app program doesn't actually have to know.
An object pointer is returned from an object factory. How that factory allocates memory for the object can be up to the factory.
Quote:
However, a realistic BASIC interpreter has to be able to dynamically allocate and deallocate memory as variables are created, modified and destroyed. Garbage collection also gets into the picture in the case of string management, which in itself could be complicated.
Dynamic as in at run time - true, but not necessarily heap based.
Allocating and deallocating memory for variables does not necessarily have to be done with dynamic (heap) allocations. A statically allocated pool of variables available to be assigned works quite well. One megabyte could be reserved to hold a lot of 32 bit integer variables with names and handles for implementing lists. Note that having larger amounts of memory available makes this practical. One approach to strings would be to use 256 byte max length string vars. 1000 strings * 256 bytes is only 256k of memory. However, If the system is limited to 8kB of memory then some form of dynamic sizing of variable areas is probably required.