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
The default nature of an object's clone() function automatically provides a shallow copy. So to need a deep copy the classes have to be edited or adjusted.   Shallow co

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

State in brief about the java Java is a object-oriented, simple, distributed, robust, interpreted, architecture-neutral, secure, portable, multi-threaded, high- performance and

Develop a Supply Chain Management Project Description: Supply Chain Management from HK and China Skills required is Java

Develop a simple polling (voting) web application according to the following specifications: Initially a page should be presented to the user where he can enter his/her name

Question 1: a) What is an "Operating System"? b) Describe the four main computer system components. c) Describe and compare "Parallel Systems" and "Distributed Systems

Explain what is Object in JAVA language? They are foundation of object oriented language. They are data structure holds data fields and properties and methods

Describe, in general, how java garbage collector works?

An ActionForm is a JavaBean that extends org.apache.struts.action.ActionForm.  ActionForm handles the session state for web application and the ActionForm object is automatically p

Explain the Execute phase of Java Program Development Finally in phase computer, under the control of its CPU, interprets program one bytecode at a time. Hence performing