java JVM

await 2021-09-15 07:22:36
java jvm


JVM

194. The way jvm The main components of ? And its role ?

Class loader (ClassLoader)

Run time data area (Runtime Data Area)

Execution engine (Execution Engine)

Local library interface (Native Interface)

Function of components : First through the class loader (ClassLoader) Will be able to Java Code into bytecode , Run time data area (Runtime Data Area) Then load the bytecode into memory , And bytecode files are just JVM A set of instruction set specifications , It can't be executed directly by the underlying operating system , So you need a specific command parser execution engine (Execution Engine), Translate bytecode into underlying system instructions , Give it to CPU To carry out , In this process, you need to call the local library interface of other languages (Native Interface) To implement the function of the entire program .

195. The way jvm Run time data area ?

Program counter 、 Virtual machine stack 、 Native Method Stack 、 Pile up 、 Method area

Some regions exist with the start of virtual machine process , Some regions are created and destroyed depending on the start and end of the user process .

  1. Talk about the difference between stacks ?
  2. Stack memory stores local variables while heap memory stores entities ;
  3. Stack memory is updated faster than heap memory , Because the life cycle of local variables is very short ;
  4. The variables stored in the stack memory will be released once the life cycle is over , The entity stored in heap memory will be collected by garbage collection mechanism from time to time .
  5. What are queues and stacks ? What's the difference? ?

Queues and stacks are used to pre store data .

Queues allow first in, first out retrieval elements , But there are exceptions ,Deque Interface allows elements to be retrieved from both ends .

Stack and queue are very similar , But it runs to retrieve elements last in, first out .

  1. What is the parent delegate model ?

Before introducing the parental delegation model, let's talk about the classloader . For any class , It needs to be established by the class loader that loads it and the class itself JVM Uniqueness in , Every classloader , All have a separate class namespace . Class loader is to set... According to the specified fully qualified name class File loading to JVM Memory , And then convert it to class object .

Classloader classification :

Start class loader (Bootstrap ClassLoader), It's part of the virtual machine itself , Used to load Java_HOME/lib/ In the directory , Or be -Xbootclasspath The class library in the path specified by the parameter and recognized by the virtual machine ;

Other class loaders :

Extend the classloader (Extension ClassLoader): Responsible for loading libext Directory or Java. ext. dirs All class libraries in the path specified by the system variable ;

Application class loader (Application ClassLoader). Responsible for loading user class path (classpath) The specified class library on , We can use this classloader directly . General situation , If we don't have a custom classloader, we use this loader by default .

Parent delegation model : If a class loader receives a class load request , It will not load the class itself first , Instead, delegate the request to the parent loader to complete , This is true of classloaders at every level , In this way, all the load requests will be sent to the boot class loader at the top level , Only when the parent load cannot complete the load request ( The required class was not found in its search scope ) when , The child loader will try to load the class .

  1. Talk about the execution of class loading ?

Class loading is divided into the following 5 A step :

load : Find the corresponding class File and import ;

Check : Check loaded class The correctness of the document ;

Get ready : Allocate memory space for static variables in a class ;

analysis : The process of virtual machine replacing symbolic reference in constant pool with direct reference . Symbolic reference is understood as a sign , In direct reference, it points directly to the address in memory ;

initialization : Perform initialization on static variables and static code blocks .

  1. How do you determine if an object can be recycled ?

There are generally two ways to judge :

Reference counter : Create a reference count for each object , Counter with object reference +1, Count when reference is released -1, When the counter is 0 Can be recycled . It has a disadvantage that it can't solve the problem of circular reference ;

Accessibility analysis : from GC Roots Start looking down , The path a search takes is called a reference chain . When an object arrives GC Roots When no chain of references is connected , This object can be recycled .

  1. java What are the reference types in ?

Strong citation 、 Soft citation 、 Weak reference 、 Virtual reference ( Ghost quotes / Phantom reference )

  1. The way jvm What are the garbage collection algorithms ?

Mark - Clear algorithm

Mark - Sorting algorithm

Copy algorithm

Generational algorithm

  1. The way jvm What garbage collectors are there ?

Serial: The first single threaded serial garbage collector .

Serial Old:Serial Older versions of the garbage collector , It's also single threaded , It can be used as CMS Alternative plan of garbage collector .

ParNew: yes Serial Multithreaded version of .

Parallel and ParNew Collectors are similar to multithreading , but Parallel Is a throughput first collector , We can sacrifice the waiting time for the throughput of the system .

Parallel Old yes Parallel Old generation version ,Parallel Using the memory recovery algorithm of replication ,Parallel Old Using tags - A memory recovery algorithm for defragmentation .

CMS: A kind of collector aiming at obtaining the shortest pause time , just the thing B/S System .

G1: One that takes into account throughput and pause time GC Realization , yes JDK 9 Future defaults GC Options .

  1. So let's talk about that CMS Garbage collector ?

CMS It's English Concurrent Mark-Sweep For short , It's a garbage collector that gets the shortest recovery pause time at the expense of throughput . For applications that require server response speed , This kind of garbage collector is very suitable . Start up JVM Plus “-XX:+UseConcMarkSweepGC” To specify the use of CMS Garbage collector .

CMS Using tags - Implemented by clearing algorithm , So in gc A large number of memory fragments are generated , When the remaining memory can not meet the program running requirements , The system will appear Concurrent Mode Failure, temporary CMS Will be used Serial Old Garbage removal by recycler , The performance will be reduced at this time .

205. What are the new generation garbage collectors and old generation garbage collectors ? What's the difference? ?

New generation recycler :Serial、ParNew、Parallel Scavenge

Old generation recycler :Serial Old、Parallel Old、CMS

Whole stack recycler :G1

The new generation of garbage collectors generally use the replication algorithm , The advantage of replication algorithm is high efficiency , The disadvantage is low memory utilization ; The old generation recycler generally uses the mark - Garbage collection by sorting algorithm .

  1. Briefly describe how the generational garbage collector works ?

The generational recycler has two partitions : The old generation and the new generation , The default space of the new generation accounts for 1/3, The default proportion of the old generation is 2/3.

The new generation uses replication algorithms , In the new generation 3 Zones :Eden、To Survivor、From Survivor, Their default share is 8:1:1, Its execution process is as follows :

hold Eden + From Survivor Live objects put To Survivor District ;

Empty Eden and From Survivor Partition ;

From Survivor and To Survivor Zoning exchange ,From Survivor change To Survivor,To Survivor change From Survivor.

Each time the From Survivor To To Survivor Objects that survive on move , age +1, When age arrives 15( The default configuration is 15) when , Upgrade to old generation . Big target will also directly enter the old generation .

When space occupation reaches a certain value, global garbage collection will be triggered , Generally, we use the execution algorithm of tag collation . All the above steps constitute the overall implementation process of the whole generation of garbage collection .

  1. The way jvm Tools for tuning ?

JDK It comes with a lot of monitoring tools , All in JDK Of bin Under the table of contents , The most common one is jconsole and jvisualvm These two view monitoring tools .

jconsole: Used to deal with JVM Memory in 、 Thread and class monitoring ;

jvisualvm:JDK All around analysis tool , Can be analyzed : memory dump 、 Thread snapshot 、 Program deadlock 、 Monitor changes in memory 、gc Change, etc .

  1. frequently-used jvm What are the tuning parameters ?

-Xms2g: The initial push size is 2g;

-Xmx2g: Maximum heap memory is 2g;

-XX:NewRatio=4: Set the memory ratio of the young to the old to 1:4;

-XX:SurvivorRatio=8: Setting up the new generation Eden and Survivor The ratio is 8:2;

–XX:+UseParNewGC: Specify the use of ParNew + Serial Old Garbage collector combination ;

-XX:+UseParallelOldGC: Specify the use of ParNew + ParNew Old Garbage collector combination ;

-XX:+UseConcMarkSweepGC: Specify the use of CMS + Serial Old Garbage collector combination ;

-XX:+PrintGC: Turn on Printing gc Information ;

-XX:+PrintGCDetails: Print gc Details .

This article altogether 2018 Number of words , Average reading time ≈ 6 minute

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

版权声明
本文为[await]所创,转载请带上原文链接,感谢
https://javamana.com/2021/09/20210909125824208Q.html

  1. Design pattern -- agent pattern
  2. Huawei Java Senior Engineer interview question, Byte Jumping thousand Selected Interview Question is still not Brushed!
  3. 双非本科字节跳动Java面试题分享,一篇文章教你搞定计算机网络面试,
  4. 又到一年金三银四,2021最新Java笔试题及答案,
  5. Huawei Finance and Economics 2021 Spring Recruitment interview, what is distributed Lock?Pourquoi utiliser des serrures distribuées?
  6. Un an plus tard, Golden, Silver, Silver, and Silver, 2021, the latest Java written Examination Questions and Answers,
  7. Partage de questions d'entrevue Java à double saut d'octets non - premier cycle, un article vous apprend à gérer l'entrevue réseau informatique,
  8. Computer graduation project java online voting system based on SSM
  9. K8s gestion des ressources (opérations de base)
  10. 又到一年金三銀四,2021最新Java筆試題及答案,
  11. Collection de code de base JavaScript (1)
  12. Vérification des permissions d'interface pour le démarrage du printemps à l'aide d'annotations personnalisées AOP +.
  13. Vérification des permissions d'interface pour le démarrage du printemps à l'aide d'annotations personnalisées AOP +.
  14. Cloud Security Daily 210914: Red Hat Jboss Middleware Platform found important Security Vulnerability and needs to be upgraded as soon as possible
  15. 吐血整理,腾讯团队实力打造spring入门教程,
  16. 史上最全的微服务专业术语面试50问,字节跳动Java岗经典面试真题,
  17. Absolument!C'est l'analyse la plus détaillée du code source de hashtap que j'ai jamais vu!
  18. Computer graduation project Java logistics order management system of logistics company based on SSM
  19. Talk about Kafka: source code analysis of producer
  20. [springboot2 starts from 0] development tips - Lombok, devtools, spring initailizr
  21. 国内一线互联网公司面试题汇总,2021年大厂Java岗面试必问,
  22. 啃完吃透保你涨薪5K,熬夜整理小米Java面试题,
  23. 和字节跳动大佬的技术面谈,Redis成神之路电子版教程已问世,
  24. Le terme professionnel le plus complet de l'histoire des micro - services interview 50 questions, Byte Jumping Java post Classic interview vrai problème,
  25. After using mybatisplus, I haven't written SQL for a long time
  26. [springboot2 starts from 0] how to write a springboot application?
  27. Huawei cloud guassdb (for redis) released a new version, and the two core features were officially unveiled
  28. 和字節跳動大佬的技術面談,Redis成神之路電子版教程已問世,
  29. 啃完吃透保你漲薪5K,熬夜整理小米Java面試題,
  30. Avec l'interview technique du gigolo, le tutoriel électronique redis est sorti.
  31. Après avoir mangé, assurez - vous d'augmenter votre salaire de 5K et de rester debout tard pour trier les questions d'entrevue Java de millet.
  32. Résumé des questions d'entrevue pour les entreprises Internet nationales de première ligne, qui doivent être posées lors de l'entrevue d'emploi Java de la grande usine en 2021,
  33. Le tri des crachats de sang, la force de l'équipe Tencent pour créer le tutoriel d'introduction au printemps,
  34. Java and scala concurrency Fundamentals
  35. Analysis of java thread source code based on Hotspot
  36. 國內一線互聯網公司面試題匯總,2021年大廠Java崗面試必問,
  37. Introduction au module de contrôle de Connexion MySQL
  38. 大厂高级测试面试题,Java面试基础技能罗列,
  39. Comprendre l'architecture sous - jacente d'InnoDB en exécutant une instruction
  40. Chargeur de classe 1 Tomcat
  41. 小白也能看懂的dubbo3应用级服务发现详解
  42. SpringBoot异步使用@Async原理及线程池配置
  43. Questions d'entrevue de test avancé de Dachang, liste des compétences de base de l'entrevue Java,
  44. SpringBoot异步使用@Async原理及線程池配置
  45. Springboot utilise asynchrone le principe @ async et la configuration du pool de threads
  46. Détails de la découverte du Service d'application Dubbo 3 que Xiaobai peut également comprendre
  47. Springboot utilise asynchrone le principe @ async et la configuration du pool de threads
  48. 如何强大且优雅的搞定Linux文件系统,算法题 JVM,
  49. 太牛了,阿里P7架构师带你看透maven的来龙去脉,
  50. Oracle central et Oracle décentralisé
  51. java JavaBean
  52. Java wrapper type
  53. Java super keyword
  54. Java static keyword
  55. Java this keyword
  56. Java interface
  57. 太牛了,阿裏P7架構師帶你看透maven的來龍去脈,
  58. C'est génial, l'architecte Ali p7 vous montre à travers Maven.
  59. Comment traiter le système de fichiers Linux avec puissance et élégance, algorithme JVM,
  60. Usage of Java scanner