Java Virtual machine learning-JVM memory Management: In-depth garbage collector and memory allocation policy (4)

Source: Internet
Author: User

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

Overview:

Speaking of garbage collection (garbage Collection, hereinafter referred to as GC), most people regard this technology as the companion product of the Java language. In fact, the history of GC is far more remote than Java, and in 1960, Lisp, born in MIT, was the first language to actually use memory dynamic allocation and garbage collection techniques. When Lisp was still embryonic, people were thinking about 3 things the GC needed to do: which memory needed to be recycled? When do I recycle? How to recycle?

After half a century of development, the current memory allocation strategy and garbage collection technology is quite mature, everything seems to enter the "Automation" era, then why do we have to understand the GC and memory allocation? The answer is simple: when it comes to troubleshooting various memory overflows and leaks, when garbage collection becomes a bottleneck for higher concurrency, we need to monitor and regulate these "automated" technologies.

Return the time from 1960 to the present, back to our familiar Java language. In the first chapter of this article, we describe the parts of the Java Memory Runtime area, where the program counter, VM stack, local method stack three regions are born with threads, and the frames in the stack are organized into stack operations with the method entering and exiting. , how much memory is allocated in each frame is basically known at the time the class file is generated (some optimizations may be made by JIT dynamic late compilation, but in general it can be seen as a compile time), so there is a high level of certainty in memory allocation and recycling in these areas, So there is no need to think too much about recycling in these areas. While the Java heap and the method area (including the run-time pool) are different, we must wait until the program actually runs to know which objects will be created, and this part of the memory allocation and recycling is dynamic, and the subsequent discussion in this article, "Memory" allocation and recycling refers only to this part of memory.

Java Virtual machine learning-JVM memory Management: In-depth garbage collector and memory allocation policy (4)

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.