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 a Java class that generates a random integer (between 1 and 250). Call the class GenKeys. GenKeys should have a least one method that returns the integer random number. Gen K

consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is represen

h there, i want you please to make an full assignment due in Friday :)

Develop Program using Interactive Brokers API Project Description: We require a Matlab function using the Interactive Brokers API for real time trading with three arguments:


Two XML configuration files are uses by The Validator Framework validator-rules.xml and validation.xml. The validator-rules.xml shows the standard validation routines, these are re

State about the JVM? JVM is the acronym which stands for 'Java virtual machine'. JVM provides execution environment. JVM isn't platform independent. JVM is Java

Question : (a) Class file verification in CLDC is different from class file verification in J2SE. Explain and discuss how and why it is different, illustrating your answer

Different modules in spring framework are:- a)  The Core container module b)  AOP module (Aspect Oriented Programming) c)  Application context module d) JDBC abstractio

Write HTML and JavaScript code which displays a textbox and button on a web page? While user enters text in the text box and clicks the button it displays in that text in the m