Java Runtime memory allocation heap and stack differences

Source: Internet
Author: User
Java run-time memory allocation

A Java process can contain multiple threads

A Java process corresponds to a unique JVM instance

A JVM instance uniquely corresponds to a heap

Each thread has a private stack of its own

You can also see the heap of threads sharing processes, but not the stack
This article has a thread and a process surface question.

Heap

The heap is shared by threads
A process with only one heap
The heap holds the object itself and the array itself

In Java, arrays (such as int[]) also inherit object objects, not inheritance object[]

Stack

Data structure inside said, stack is first into the back out
The stack holds references to objects (declarations and reference objects are sequential and may also be related to stacks)

Heap and Stack comparisons

Stack is faster than heap, heap allocation is more flexible than stack
Generally, the available heap space is larger than the stack

Static Storage Area

There seems to be an objection to this, does Java have any static storage area?
Usually with static keywords stored in the static storage area

Don't dig into the details.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java Runtime memory allocation heap and stack differences

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.