View RSS Feed

Core Java

Core Java tutorials.

  1. Java stack and heap memory

    by , 01-08-2012 at 12:43 PM
    Heap is used to store new objects created by Java. Stack is used to store primitive data types like int and double when they are declared locally. These primitive data types are stored on heap when they are declared globally. Whenever a Java method is called, all the local variables are pushed to stack and its pointer is decremented after completion of that method call. In a multithreaded application only one heap is used and each thread contains its own stack. So do not declare your data globally ...