What is the difference between stack and heap memory allocation, and how does it impact mobile performance?