Understanding stacks, heaps, stacks in Java virtual machines

Source: Internet
Author: User

Java's JVM memory can be divided into 3 zones: heap, stack (stack), and method area

  • Stack area:
  1. Each thread contains a stack that stores only the underlying data types and custom object references (not objects)in the method (not including the object's member variables), and objects are stored in the heap area
  2. The data in each stack (both the original type and the object reference) is private and the other stacks are inaccessible.
  3. The stack is divided into 3 parts: the basic type variable area, the execution environment context, the operation instruction area (holds the operation instruction).
  • Heap Area:
  1. All of the stored objects are object instances, each containing a class information (class information is stored in the method area).
  2. The JVM has only one heap area (heap) that is shared by all threads , the heap does not hold the base type and object references, only the object itself, and almost all object instances and arrays are allocated in the heap.
  • Method Area:
  1. Also called the static zone, like the heap, is shared by all threads. It is used to store data such as class information, constants, static variables, and code compiled by the immediate compiler that have been loaded by the virtual machine.

Portal: https://www.zhihu.com/question/29833675

Understanding stacks, heaps, stacks in Java virtual machines

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.