How does java allocate heap and stack memory?, JAVA Programming

Each time an object is started in Java it goes into the area of memory named as heap. The primitive variables like double and int are allocated in the stack, if they are local instances and in the heap if they are member variables. In Java functions and local variables are pushed into stack when a function is called and stack pointer is decremented when a method invoke is finished. In a multi-threaded application each thread may have its own stack but will share the similar heap. That is why care could be taken in your code to avoid any concurrent access concern in the heap space. The stack is thread-safe because each and every thread will have its own stack with say 1MB RAM allocated for each thread but the heap is not thread-safe unless protected with synchronization through your code. The stack space may be increased with the -Xss option.

Posted Date: 7/25/2012 2:25:41 AM | Location : United States







Related Discussions:- How does java allocate heap and stack memory?, Assignment Help, Ask Question on How does java allocate heap and stack memory?, Get Answer, Expert's Help, How does java allocate heap and stack memory? Discussions

Write discussion on How does java allocate heap and stack memory?
Your posts are moderated
Related Questions
Explain the both HashSet and TreeSet? HashSet is an unordered, unsorted Set. It's a Collection set which restrict duplicate elements and also repositioning of elements. I

Differentiation the JDK 1.02 event model and the event-delegation model introduced with JDK 1.1?

String concatenation and comparison public class StringTest { public static void main(String[] args) { int i = 4; int j = 5; System.out.println ("Hello" + i); // wi

I neeed to create a basic code to do the following. the class is entry level and I would appreciate a brief explanation as to why you do each bit. Write a program that displays t

Explain the user defined Exceptions. User Defined Exceptions are the exceptions which are defined by user for specific purposed. This enables custom exceptions to be generated

How we can changing the Implementation ? Suppose the Car class requires to be used in a simulation of New York City traffic in that each actual car on the street is represente

do you have example of a simple midlet game ?

can we develop paint user can draw his charcters and images in swing

Develop Billing Software Project Description: Need software to print bills on A4 paper in the format provided. The details are shown below - 1. Serially generated Invoice

I have a parser. it is written in Java. I need to add a hash table to it. I am wondering about if you can do it.