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
In JavaScript, what is event handling? What are the two types of events? In JavaScript capturing events and responding to them is event handling. The system sends events to the

What is Color in AWT? Color is a class in the AWT. Individual colors such as red or mauve are examples of this class, java.awt.Color. Be sure to import it if you want to use ot

Assignment 3 Project Proposal Documentation Description Marks out of Wtg(%) Due date Assignment 3 100 35% 15/09/14 In the assignment we will start analysing and designing the

Using RMI, program a PONG game that enables two users to play against one another. Pong class: package graphics;/* * Copyright (c) 2006, Your Corporation. All Rights Reserved. */

Deliverable:  1) WAR file for your application that can be deployed and run on TomcaT (War file must contains the Java source code) Requirement for application: 1. Application m

Develop a Adobe Air Native Extension Project Description: We are seeking someone that must create an adobe native extension for the subsequent SDK: Develop a Adobe Air Nat

Explain the char data type in java? A char is a single character in which a letter, a digit, a punctuation mark, a tab, a space or something same. A char literal is a single on

This project simulates a remote procedure call on a client-server architecture. You will create both the client and the server. The server will maintain a linked list. It must N

1. Create a text file (you can name it sales.txt) that contains in each line the daily sales of a company for a whole month. Then write a Java application that: a. asks the user fo

Explain the term array and Scope of Variable? Defining the space in that a variable is effective is known as describing the scope of a variable. A variable can be either local