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
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. */

What is difference between Design and System Architecture? System architecture is the conceptual design which defines the structure and/or behavior of a system. Whereas designs

Project Description: I want to modify Joomla component. Now there is Akeeba subscription component on this site. It works and the whole thing is fine, but there is no "teaser

Write a program that reads both the girl and boy files into memory using arrays. Then, allow the user to input a name. The program should search through both arrays. If there is

What is the difference among session scope and request scope when saving formbean? Ans) When the scope is request, the values of formbean would be there for the current request.

I'm seeking to hire someone to build me a program that can solve a php captcha. It should be a web service or script. You will write it in any language since i will execute i ca

How do you decide when to use HashMap and when to use TreeMap? When we want to perform deletion, insertion and locate elements in a Map then HashMap is used. Whereas TreeMa

Diffentiate Local and Global Variables? Local or function level variable effective just in the function in that they are declared although global variables visible everywhere o

Describe synchronization in respect to multithreading. With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared res

Classes are attached into the JVM as they are referenced by name in a class that is already running in the JVM. So, how is the staring class loaded? The very first class is espec