Byte beating Wuhan recruit 2,000 people, from manufacturers Offer, you short of this Java dry! | Force plans ...

[Editor's note] CSDN gold, three silver and four recruiting season, and the epidemic will not affect too much. According to the official propaganda to mobilize bytes, the Division decided to expand the scale of recruitment this year in Wuhan, providing nearly 2,000 jobs, to promote local talent employment. Also appeared online remote entry byte beating people, not to the company received news of the laptop. Rest assured, this is not advertising, just to illustrate, the epidemic unbeatable development of Chinese enterprises, but does not block China's demand for labor. And if you're interviewing for jobs maker Java, this article should probably be your "side by."

Author | _ Chen haha

Zebian | Hu Weiwei

Exhibition | CSDN (ID: CSDNnews)

In this article, we will examine the Java garbage collection, and the importance of its work.

The definition of Java garbage collection

Java garbage collection process is a Java program performs automatic memory management. Java programs compiled to bytecode, the Java Virtual Machine can (referred JVM) to run on. When the Java program to run on the JVM, it will create objects on the heap, which is dedicated to the memory part of the program. In the end, it will no longer require certain objects. Garbage collector to find these unused objects and delete them to free up memory.

How Java garbage collection work

Java garbage collector is an automatic process. Programmers do not need to explicitly mark the object to be deleted. Garbage collection in the JVM in the realization. Each JVM garbage collection can be achieved, but it's nice. The only requirement is that it conforms to the JVM specification. Although there are many JVM, but Oracle's HotSpot is by far the most common. It provides a powerful and sophisticated garbage collection options.

Although optimized HotSpot having a plurality of garbage collectors for various use cases, but all the garbage collectors follow the same basic process. The first step, object recognition and unreferenced marked as garbage collection. The second step, delete marked objects. (Optional) can be compressed memory after a garbage collection to delete the object, so that remaining objects in contiguous blocks at the beginning heap. Compression process in order to make it easier for the memory allocated after the allocated memory block existing object to the new object.

All HotSpot garbage collector have achieved a generational garbage collection policy by age objects. The basic principle behind the generation garbage collection is that most objects are short-lived, and will soon be garbage collected after it is created.

Heap divided into three parts:

The younger generation: newly created objects began in the younger generation. The younger generation subdivided into Eden Survivor space and all space, all new objects are beginning to run in Eden space, after which the end of a garbage collection cycle, the object is removed from the Eden. When the object is collected from the Young Generation, which is a secondary garbage collection events.

The older generation: long-lived objects eventually migrate from the older generation to the younger generation. When the object from the previous generation garbage collection, which is a major garbage collection events.

Permanent generated: metadata (e.g., classes and methods) stored in a permanent generation. No longer in use class may be collected from a permanent generational garbage.

During a complete garbage collection event, on behalf of all the objects in use will not be garbage collected.

There are four HotSpot garbage collector:

Serial: All serial garbage collection events are carried out in one thread. Compression is performed after each garbage collection.

Parallel: a plurality of secondary threads for garbage collection. Single-threaded garbage collection for large and old-style compression. In addition, Parallel Old variables using multiple threads main garbage collection and Old Generation compression.

The CMS (concurrent mark Scan): Using the same algorithm in parallel, a plurality of secondary threads for garbage collection. Large garbage collection is multi-threaded, such as Parallel Old, but CMS application processes running at the same time, in order to minimize the "Stop the World" event (ie, stop the application when the garbage collector is running). No compression is performed.

G1 (Garbage priority): the latest garbage collector is designed to replace CMS. It is like CMS as parallel and concurrent, but compared with older garbage collector, it works quite different.

The benefits of Java garbage collection

Java garbage collection greatest benefit is that it can automatically handle unused objects deleted or inaccessible objects to the release of significant memory resources. Use language without garbage collection (such as C and C ++) work programmers must implement manual memory management in its code.

Despite the extra work, but some programmers still favor manual memory management is better than garbage collection, mainly for reasons of control and performance. Although the debate about memory management method continues, but garbage collection is now standard for many popular programming language component. For programs have a negative impact on performance of the garbage collector, Java provides a number of options to adjust the garbage collector to improve its efficiency.

Java Garbage Collection Best Practices

For many simple applications, Java garbage collection is not a conscious thing programmers need to consider. However, for Java programmers want to improve skills, understanding Java garbage collection works and how to adjust them is very important.

In addition to the basic mechanism for garbage collection, one of the most important points to understand garbage collection in Java is that it is not deterministic garbage collection can not predict when running. The code can be included in a prompt to use System.gc () or Runtime.gc () method runs the garbage collector, but they can not guarantee the garbage collector will actually run.

The best way to adjust the Java garbage collection flag is set on the JVM. Flag can adjust the garbage collector (eg, Serial, G1, etc.) to be used, the initial and maximum heap size, size (for example, Young Generation, Old Generation) stack segment, and so on. The nature of the adjustment application is good to set the initial guidelines. For example, high efficiency parallel garbage collector, but often leads to "stop the world" event, to make it more suitable for back-end processing, in this case it can be a long pause garbage collection.

On the other hand, CMS garbage collector is designed to minimize the pause, making it ideal for responsiveness is important GUI applications. By changing the stack or heap size and use the measuring tool jstat like garbage collection efficiency to complete additional fine-tuning.

Original link:

https://blog.csdn.net/qq_39390545/article/details/104457216

【End】

Epidemic prevention, how to return to work in parallel? Tianyun launched artificial intelligence data monitoring program! In the end how to do advance the prevention, rather than after the fact? 8 pm Thursday , the day the cloud data VP Yong for you reveal the answer! Scanning the next Fanger Wei code free registration ~

Recommended Reading 

Baidu established Internet hospital; nail recruit students to experience products division; iOS 13.4 on line | Geeks headlines

How to get through AI edge computing "Renduermai"?

5 bn bo suspected data leak, how to avoid stepping Python reptile sinkhole?

@ developers, Microsoft CEO Satya led the 60 large build-up to make coffee, you dare to take it?

claiming Nakamoto he was angry judge hate: your testimony there is no credibility!

Your Business Under what circumstances need to artificial intelligence? Take a look at what conditions and capabilities you need to have it!

You look at every point, I seriously as a favorite

Released 1878 original articles · won praise 40000 + · Views 17,070,000 +

Guess you like

Origin blog.csdn.net/csdnnews/article/details/105108970