Growing the Heap!
I am not that good with computers but I’m educated enough to know that YouTube videos that talk about the heap growing towards the stack are about a quarter century out of the date.
I can remember a time with Macintosh System 7 when you could set the amount of memory available to each program, which in turn would define how large the heap would be. Nowadays when you call malloc, the Memory Management Unit allocates heap space whereever there is free space of the requested size – the heap is no longer necessarily consecutive.
Memory management units are pretty smart with protected memory. If you are an ordinary process and you don’t have elevated permissions and try to read or write to a section of memory not associated with the process the memory management unit will raise an exception, deny the access and possibility the operating system will kill the process.
Now it is accurate that memory management units don’t provide for true garbage collection until a process exits and with many languages such as C or C++ things remain on the heap until they are manually deleted or the process ends. But that is done for reasons of speed and memory – if you have automatic garbage collection than you have to track when every pointer is destroyed.