In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to understand Java garbage collection". In daily operation, I believe many people have doubts about how to understand Java garbage collection. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to understand Java garbage collection"! Next, please follow the editor to study!
Java memory area
How many parts does the Q:Java virtual machine specification divide into the memory managed by the JVM virtual machine? If it is a multiple-choice topic, it is estimated that it will be given to some that are not in it, such as direct memory.
A: program counter, java virtual machine stack, local method stack, method area, heap.
Allocation of java objects on memory:
§GC strategy
Q:java uses the root search algorithm to determine whether objects are in stock and which objects can be used as GC Roots?
A:
Objects referenced in the virtual machine stack (local variables in stack frames)
Objects referenced by static properties of a class in the method area
Objects referenced by constants in the method area
Reference object of JNI (Native method) in the local method stack
Q: which block is the algorithm of tag clearing, mark finishing, or copying?
A: the replication algorithm is faster.
The meanings of the three algorithms are as follows:
What algorithm is used by Q:SerialOld?
A: tag finishing algorithm, which belongs to the old age algorithm.
The change diagram of each collector is as follows, focusing on the changes and differences
Will Q:fullGC occur in the old age zone or the Cenozoic era?
A: it will happen in the geriatric area. On the contrary, minorGC is generally sent in the Cenozoic area.
The occurrence process of the new generation, the old generation, minorGC and fullGC is as follows:
Q: when will the class objects (that is, class objects) in the method area be recycled?
A: all instances are recycled, the corresponding classLoader is also recycled, and class objects are no longer referenced or reflected (how can I be sure? What I saw in the book, I don't understand)
§finalized and GC
Q: when will the object's finalized method be called
When A:JVM starts garbage collection and the object is to be collected.
Finalized should be more of a specification. Many specifications require us not to implement finalized ourselves. After all, there is too much uncertainty.
§Java virtual machine GC parameter configuration
I suddenly remembered that when I was looking at the java virtual machine, I skipped those parameters, and I couldn't remember it.
But now I find that I still have to learn, so hurry up and make up for it.
Q:
Comparison of-client and-server
() start faster
() High performance and memory management efficiency (note that fast startup and good performance are not the same thing)
Desktop applications are generally used (), servers are generally used ()
A:
(- clien) start faster
(- server) performance and memory management efficiency
Desktop applications are generally used (- clien), servers are generally used (- server)
There are four memory-related parameters
-Xmn-Xms-Xmx-Xss
Answer the following questions:
Q:
The initial heap memory used to configure java is ()
A:
-Xms.
-X, memory, size, memory size
Q:
The maximum value used to configure the java heap is ()
A:
-Xmx.
-X, memory, max
Maximum memory
Q: if not set, what are the default sizes of-Xms and-Xmx, respectively?
A:
If not, the two are equal. The default is physical memory / 64 (less than 1G).
Q: the maximum value used to configure the new generation memory size is: ()
You asked me what is the new generation of memory?
This is the memory size of one E zone plus two S zones.
A:
-Xmn.
-X, memory, new
Similarly, there are-XX:NewSize and-XX:MaxNewSize.
Q: how to calculate the memory size of the old age according to the above parameters?
A:
Value of Xmx (heap maximum)-value of Xmn (Cenozoic memory)
Q: what is the () used to configure thread stack memory? What other parameter is there to replace?
A:
-Xss. The other is-XX:ThreadStackSize.
-Xss means-X stack size.
There are three parameters related to gc
-Xnoclassgc-Xincgc-Xloggc:file
Answer the following questions:
Q:
What can be used to turn off the gc function for class objects is ()
What can be used to reduce the program pause time of gc is ()
The one used to output gc related logs is ()
A:
What can be used to turn off the gc function for class objects is (- Xnoclassgc)
What can be used to reduce the program pause time of gc is (- Xincgc)
The one used to output gc related logs is (- Xloggc:file)
What is Q:-verbose usually used for?
A:
Query for gc questions.
-verbose:class outputs information about jvm loading classes, which can be diagnosed when jvm reports that the class cannot be found or that there is a class conflict.
-verbose:gc outputs the relevant information about each GC, which will be described in more detail later.
-verbose:jni outputs information about native method calls, which is generally used to diagnose jni call error messages.
Q: what memory is set by-XX:PermSize and-XX:MaxPermSize?
A:
The memory of the method area. It's the one in the picture at the beginning.
By configuring-XX:PermSize and-XX:MaxPermSize to control the size of this memory, jvm allocates a contiguous block of memory according to-XX:PermSize initialization at startup, which may be wasteful if the-XX:PermSize setting is too large. If the setting of Max is small, it may be omm.
What kind of memory are Q:-XX:MetaspaceSize and-XX:MaxMetaspaceSize?
A:
Metadata area memory. Introduced by java8 to replace the perm area above.
No matter how the parameters-XX:MetaspaceSize and-XX:MaxMetaspaceSize are set, as the class loads more and more, it expands and adjusts until MetaspaceSize (default 20.8m if not configured) triggers FGC, the upper limit is-XX:MaxMetaspaceSize, and the default is almost infinite.
At this point, the study on "how to understand Java garbage collection" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.