So, my question is why heap memory exists. People say that it is unsafe and slow, whereas the stack is fast and safe. But if so, then why do people use the heap memory? And why can't the stack's capacity be more than 1 mb? I know that heap memory is visible to all of the threads whereas stack memory is only readable by one thread. But are there any other reasons why you should be using heap memory? I have heard that you can run out of stack memory, but once again, why is it only 1 mb.
I have tried googling the answer to this question, but I was not able to find a definitive answer. The only thing which I have found was how to use the heap memory and how to do that safely but never have I found the answer to my question.