memory allocation in Java

Source: Internet
Author: User

Java Memory allocation

A: Stack stores local variables


B: Heap Storage for all new


C: Method Area (in-memory of the method area)

When class loads, the method information is stored in a piece of memory called the method area, and is not stored in the heap with the object as you create it;

D: Local Method Area (System-dependent)


E: Register (CPU use)

Attention:
A: A local variable is defined in the method definition or on a method declaration.

B: The difference between stack memory and heap memory
Stack: When the data is used, it disappears. ------> Store a value type

Local variables: in the stack

Heap: Every new thing that comes out has an address---------> stores a reference type

Member variables: in the heap

Each variable has a default value
Byte,short,int,long 0
float,double 0.0
Char ' \u0000 '
Boolean false
Reference type NULL
After the data is used, it is recycled when the garbage collector is idle.

memory allocation in Java

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.