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
Luminous Jewels - The Polishing Game Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various lum


I do not understand how to do this? can someone help me?

Overall Requirements Every phone number is broken up into sections as shown below: Country Code Area Code Prefix Line Number 1 919 882 5000 Write a program to separate out a ph

In Java not all classes must be described separate from each other. You may put the definition of one class under the definition of another class. The class inside class is called

i m confused what to take as a project for final year in information tech cn u suggest some of the topic of software

What is Overloading explain with an example? Overloading is while the similar method or operator can be used on several different kinds of data. For example the + sign is used

Dynamic JAVA Class and type information is kept around at runtime. This allows runtime loading and inspection of code in a very flexible way.

What is synchronization and why is it important? With respect to multithreading, synchronization is the potential to control the access of multiple threads to shared resources.

• A Graph Data Type (including a display method to show adjacencies) • A Cycle Checker (as described in lecture notes) • An Edge class • A sorting algorithm to sort an array of Edg