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
Hospital Management System: Technology Used Java-JSP, Apache Tomcat (webserver), SQL SERVER 2000. This project is aimed at developing a web-based system for taking records

Describe Interfaces in java langauge? Interfaces are the further level of abstraction. An interface is like a class along with nothing but abstract methods and final, static fi

Explain JAR Archives ? HTTP 1.0 uses a separate connection for every request. When you're downloading several small files, the time required to set up and tear down the connec

How are this () and super() used with constructors? this() Constructors: is used to pointing current class instance. Can be used with methods or variables. Used to call

The File class encapsulates the files and directories of the local file system. The RandomAccessFile class gives the methods required to directly access data contained in any part

ineed program for dda algorithem

I want Multiplayer Backgammon Game Project Description: We want a multiplayer backgammon as short as well as long one. It should be free and on money also. The games fronted

i m working on an accounting software and need the java code for preparing trial balance report

Write a program that takes as input a sequence of transactions of the form