Heap and Stack memory allocation in java, 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.

 

1766_Untitled.png

All Java functions are automatically re-entrant. It states that various threads can be executing the same method at once, each with its own copy of the local instance. A Java method can call itself without using any special declarations. That is known as a recursive method call. Provided enough stack space, recursive method calls are completely perfect and valid in Java though it is tough to debug

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







Related Discussions:- Heap and Stack memory allocation in java, Assignment Help, Ask Question on Heap and Stack memory allocation in java, Get Answer, Expert's Help, Heap and Stack memory allocation in java Discussions

Write discussion on Heap and Stack memory allocation in java
Your posts are moderated
Related Questions
i want a full program with test about the following: linkedComputers: We will assume that a number of methods are required. These are specified below. String getComputerName() ret

i''ve done an application that calculates simplex methods i need to add big m method can any one help me?

A simple Desktop Software Project Description: We want a tool that could convert Flash Games into HTML5 Files. These are not tedious games, very simple game. I have attached

I want to know if you can help me with a javacard programming project

Explain about the Static classes A  class  can  have  static  variables    and    methods.    Static    methods    and    variables    are  associated  with  class  itself  an

Cyclos USSD and mobile banking IVR module Project Description: We previously have a Cyclos mobile banking solution deployed on our server with SMS banking module. The solu

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

Differentiate Local and Global Variables? Local variables are the variables have limited scope although global have bigger scope Local variables are not accessed through others

Authentication is basically an identification step. Functionality used for J2EE security: Principal : An entity that may be authenticated and identified. Principal n

write a program to find the minimum no of colors to fill a board where some of the elements of different color are already placed.