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
An application server creates data for a Web server - as, collecting data from databases, processing security checks, applying relevant business programs, and/or storing the state

Machines should have Java interpreter for the Java byte code to get implemented. Linking is a very simple process and this feature helps while developing applications. Java compile

Why are JSP pages the preferred API for creating a web-based client program? Because no plug-ins or security policy files are required on the client systems (applet does). Also,

Solve Neural Network Questions Project Description: You must know  Binary Chop and Kohonen Network, Backpropagation Algorithm. Implementation is required. Can using existi

Elaborate with examples Vector or Object oriented graphics? Vector or Object-Oriented Graphics treats everything which is drawn as an object. Objects retain their identity afte

Explain the concept of Multi-Threaded- JAVA Java has a concept of concurrency wired right in to the language itself. This works out more cleanly than languages where concur

I am having an combox box and values are retrieved from the database having inputs and labels i want to created the dynamic form accroding to user input on combox box values

In JavaScript, what is event handling? What are the two categories of events? In java script we could capture events on do a few operation on the basis of which particular even

How to initialize array in java ? Individual elements of an array are referenced through the array name and through an integer that represents their position in the array. The

Why Local variable is preferred over Global variable ? In my point of view Global variable has a few advantage along with Local variables is preferred because of the subsequent