What content is stored in the stack, heap, and method area respectively?

王林
Release: 2020-06-24 16:34:28
forward
13320 people have browsed it

The stack stores values and objects of basic data types as well as references to basic data; all objects stored in the heap are objects, and each object contains information about a corresponding class; the method area is used by all threads Shared, the method area contains all class and static variables.

What content is stored in the stack, heap, and method area respectively?

(Recommended tutorial:Getting started with java development)

Heap area:

1. Storage All are objects, and each object contains information about a corresponding class. (The purpose of class is to get operation instructions)

2. JVM has only one heap area (heap) shared by all threads. Basic types and object references are not stored in the heap, only the object itself is stored.

Stack area:

1. Each thread contains a stack area. The stack only stores values and objects of basic data types and references to basic data.

2. Each thread The data in each stack (basic data types and object references) are private and cannot be accessed by other stacks.

3. The stack is divided into 3 parts: basic type variable area, execution environment context, and operation instruction area (storage operation instructions).

Method area:

1. Also called the static area, like the heap, it is shared by all threads. The method area contains all class and static variables.

2. The method area contains elements that are always unique in the entire program, such as class and static variables.

(Video tutorial recommendation:java video tutorial)

The above is the detailed content of What content is stored in the stack, heap, and method area respectively?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!