Java Memory Management

Source: Internet
Author: User

There is a high wall between Java and C + + that is surrounded by dynamic memory allocation and garbage collection techniques. People outside the wall want to go in, the people inside the wall want to go out.

1.java Memory Distribution

Program counter

Stacks (local variables, operands, dynamic links, method exits)

Each method from the call until the completion of the process, corresponding to a stack frame in the virtual machine stack into the stack of the process. The memory space required for local variables is allocated at compile time, and when entering a method, this method needs to allocate how much local variable space in the frame is fully deterministic. The size of the local variable table is not changed while the method is running.

Heap (storing object instances and arrays, also known as GC heaps)

Method area

Stores the class information, constants, static variables, and immediate compiler-compiled code data that have been loaded by the virtual machine.

2. Heap allocation method

Pointer collisions (Bump the Pointer) for garbage collection using compact policies

Idle lists (free list)

3. Object memory allocation synchronization policy

Synchronizing Memory Allocations

Tlab (local thread allocation buffer, each thread has its own buffer and only synchronizes when the buffer has been redistributed)

4. Object Space

Object header (run-time data for the object itself: Hashcode, GC generational age, lock State ...) Class meta data)

Instance data

Snap To fill

5. Object access and positioning

Using handles

Direct pointer

6. Garbage Collection Strategy

Tag-purge policy

Replication Algorithms

Tagging-sorting algorithms

7. Garbage collector

    • Serial "is a single-threaded, Stop-the-world, collector using the replication algorithm.
    • "Parnew" is a multi-threaded, Stop-the-world, using the copy algorithm of the collector. Unlike "Parallel scavenge", it can be used with the "CMS" collector. For example, "Parnew" does the synchronization required so that it can continue running in the concurrency phase of the CMS.
    • "Parallel Scavenge" is a multi-threaded, Stop-the-world, replication algorithm collector.
    • "Serial old" is a single-threaded, Stop-the-world, use tag-purge-compress collector.
    • The "CMS" (Concurrent Mark Sweep) is a concurrent, short-stop collector.
    • "Parallel old" is a multi-threaded, collector using the compression algorithm.

http://ifeve.com/our_collectors/

Java Memory Management

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.