Stack vs Heap
Learn Stack vs Heap (Object Memory, Java) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
6. Basic Concepts Two Memory Areas Every Java Program Uses When a Java program runs, the JVM splits the memory it uses into different areas. The two you'll hear about constantly are the Stack and the Heap . Stack - stores method calls and local variables. Very fast, very short-lived. Heap - stores all objects (created with new ). Larger, longer-lived, shared by the whole program.