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
BeanFactory has many executions in Spring. But one of the most useful one is org.springframework.beans.factory.xml.XmlBeanFactory, which loads its beans based on the definitions ha

For this Assignment, submit the following program: Create an application for an animal-fur trimming service. The business is open 15 weeks of the year, from April through July. The

Write the JavaScript code for the Function SumOddNumbers(maxNumber) in which can add non-negative odd numbers up to maxNumber and return their sum. Java Script Code

1-4 Problem Set: Arithmetic Consider the following statement when responding to questions 1 and 2: Jim develops 5 Java applications a year. Joe develops 10 Java applications a year

We may use the java.net.URL and java.net.URLConnection classes to start a standard HTTP connection and "tunnel" to a Web server. The server then gives this information to the s

QUESTION 3: Overloaded methods Write the overloaded method named average () for each of the following problems: a) The first method receives THREE (3) integer values and returns

For this assignment you are provided with a class called LNode which can be used as a list node for a linked list of ints. You are also provided with an abstract class called LList

Java coding required Project Description: Need to develop a website. Require Java coders urgently. Skills required are Graphic Design, HTML, PHP, Java, Website Design

State about the performance of java First versions of java were pretty slow. Java performance has gotten a lot better with aggressive just-in-time-compiler (JIT) techniques