How does java allocate heap and stack memory?, 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.

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







Related Discussions:- How does java allocate heap and stack memory?, Assignment Help, Ask Question on How does java allocate heap and stack memory?, Get Answer, Expert's Help, How does java allocate heap and stack memory? Discussions

Write discussion on How does java allocate heap and stack memory?
Your posts are moderated
Related Questions
Write down HTML or JavaScript code for the following requirements: Declare an Array along with the identifier SUBJECT having length 5. Assign subsequent values to the array par

Im receiving an error message of Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at Homework.main(Homework.java:51)

The break statement is utilized for terminating the current While or For loop and after that transferring program control towards statement just after the terminated loop. The foll

can i have code on this assignment: The code in the main method should do the following: 1. Prompt the user for a string input value for the amount in dollars and store it in a va

The roster lets you keep track of the availability ("presence") of other users. A roster also allows you to organize users into groups such as "Friends" and "Co-workers". Other IM

Differentiation between if statement and a switch statement ?

What is linear search? It is the simplest form of search. It searches for the element sequentially starting from first element. This search has a drawback if element is located

I want a viral script for facebook likes Project Description: I am seeking someone to sell me or make for me a VIRAL script for facebook likes and auto share. Skills requi

List the Parentheses used in Java language? As usual here's the output: % javac FahrToCelsius.java % java FahrToCelsius 0 -17.7778 20 -6.66667 40 4.44444 60 15.5556 80 26.6667

Struts is a framework with set of co operating servlets, classes and JSP tags that create a reusable MVC 2 design.     1. Client (Browser) : A request from the cli