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
State the Verify phase of Java Program Development Before the bytecodes in an application are executed by the java interpreter, they are verified by the bytecode verifier in

How Polylines draws in java language? Java automatically closes the polygons it draws. That is it draws polygons which look like the one on the right rather than the one on the

This assignment is a good project for working with 2 dimensional arrays. In this program, you will implement an ascii version of the classic game "Connect 4". Connect 4 is a 2 p

Normal 0 false false false EN-US X-NONE X-NONE

Take the Student Choice GUI you created in Assignment and convert it to an applet.  Because standalone GUI applications and applets are so similar, a lot of the code should be reus

Explain Overriding Methods: The Solution The object oriented solution to this problem is to describe a new class, call it SlowCar, that inherits from Car and imposes the additi

You should override the hashCode() and equals() functions from the Object class. The default implementation of the hashcode() and equals(), which are inherited from the java.

Talent agencies like ICM, CAA and Paradigm represent writers, directors and actors (among other talent).  These agencies take in hundreds of millions of dollars a year collecting 1

What is the use of Wrapper class You can create an object of Wrapper class using a String or a primitive data type Integer num = new Integer (4); or Integer num = n

Android app for evaluating of distance Project Description: The request is to prepare an app for Android. The application needs to run on tablet (7 "or larger) and the layout