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
A fictitious train company, 'Transrail', has commissioned you to write a program that manages a list of train tickets. The program should display a text menu that prompts the us

Prepare Android Antivirus with locate device capability Project Description: We need a developer that can develop an Android Antivirus similar to lookout Developer need to prov

Object Oriented Programming   Java is basically object oriented. Each line of code you write in java should be inside a class (not counting import directives). OOP fundamental

I am supposed to call an external application (which is command-line based) and send input to the application from java. I created a batch file to call the application. It successf

how can i create an E-exam application on netbeans

Write a program that uses one of the Map classes to implement a contact list. Contact information should include first name, last name, a phone number and an email address. The lis

Write an application that uses an Array to store 10messages of type String. You will store this Array with 10 messages of your choosing. For example, a message could be “I love Jav

Classifieds Android app from my Word press Classifieds website with Google gps/ map augmented reality for ads Project Description: 1. Prepare an Android Classifieds app for m

Write a program called BaseConverter that prompts (asks) the user for a base 10 number and another number, between 2 and 10 inclusive. This second number is the base to which to co

What is Bit-Mapped or Raster Graphics? Similar as object-oriented graphics, refers to software and hardware which use geometrical formulas to represent images. The other techni