You are right, of course. The array stack does not contain
vector/matrix data, but fat pointers (structs) to (re)allocated
heap objects (the matrix elements). Sizing is done automatically.
By the way, dynamic strings are treated like character vectors.
At startup, the rather small array stack is preallocated from
bottom to top with pointers and yet empty objects. On exit,
the heap objects are freed by a loop that traverses the stack.
The same procedure is used to external VECTOR or MATRIX values,
which are linked for this purpose.
Individual heap objects can be freed by setting the referencing
stack element or external value to NIL. There is no garbage
collector. I tried reference counting, but it was not worth the
hassle because my applications rarely have more than about few
dozen external objects alive at the same time.
I can't remember ever having a memory leak because all the
heap objects are referenced through the stack or through the
chain of external VECTOR/MATRIX values. So all heap objects
can be found and managed easily.