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
The basic system has to offer the following options: 1. Exit the program 2. Enter new customer The program prompts for the details of a new customer, assigns a unique cust

No, java is not fully object oriented language due to it does not support "multiple inheritance" and "pointers" which are used in C++. But, by using Interfaces we can execute multi

write complete application to play game tictactoe

Validate() : Used to validate properties after they have been populated; known as before FormBean is handed to Action. Returns a collection of ActionError as ActionErrors. Followin

In Java everything exists within a class. It describes the behavior of the class and its characteristics. Java applications and applets are built in the class. Rules present for cl

Write responsibilities of the followings 1. Developer a) Module level design. b) Coding c) Unit testing 2. Executive Team a) Responsible for the day to day operations. b) A

What are the parts of website design? Parts of web design: There are in 3 types of elements for web design and below are there names: 1. Navigation scheme 2. Overall look and

i have got project of Vending machine. would you please help me about how to start and how to use coding.thanks

Need Software protection with data files encryption Project Description: I am use to Chinese dongle sense lock clave 2, i need to prepare to dongle encryption tool same appli

Write a code in java to explain the while loop in Java? // This is the Hello program in Java class Hello { public static void main (String args[]) { System.out.print("