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
Need to prepare 18 java questions - design patterns Project Description: Hello, I require a freelancer who will create java questions for oracle exams, see the attached sampl

how much it will cost me

What is File Transfer Protocol? This protocol is used to upload the files on remote computers. This is used to transfer files among computer on TCP/IP network e.g. internet and

Each time an object is operated in Java, it goes into the area of memory named as heap. The Java heap is named the garbage collectable heap. The garbage collection may not be force

Search on column demonstration in Semantic Vector Project Description: I am preparing a research on Semantic Vectors. But I am not able to check out in a vector representa

What is Arithmetic promotion assignment and casting? In an assignment statement, i.e. if there's an equals sign, Java compares the type of the left hand side to the at last typ

Spring - JSF integration is useful when an event handler wishes to explicitly invoke the bean factory to make beans on demand, such as a bean that encapsulates the business logic t


Need JVC Everio stream converter Project Description: JVC Everio is a brand of cameras capable of real time streaming/ encodinig. To get the video from a PC or a mobile de

When should I use abstract classes and when should I use interfaces?  Use Interface, when: Design changing often or when various implementations only share method sign