首页 > 编程知识 正文

字节移动os客户端面经,base和root的区别

时间:2023-05-05 10:42:31 阅读:130548 作者:361

在最后一次面试中,我问了JVM垃圾回收算法,深入询问了GC Root的计算,然后跪了下来。 我在网上看到了一些资料,一般很模糊。 我自己整理了。 作为参考,如果有错误的地方欢迎指正。

gcroot class -由系统类加载器加载的对象。 这些类不能重用,可以将其他对象作为静态字段保留。 注意,除非相应的java.lang.Class实例以其他方式成为roots,否则通过用户定制的类加载器加载的类将不会。 rootsThread -活动线程堆栈local-Java方法的local变量或参数JNI Local -全局JNI引用(Native方法)引用的方法JNI Global -全局JNI引用moniton 不是M -的已知类型包括系统类加载器、一些JVM已知的重要异常类、为处理异常而预分配的对象以及一些自定义类加载器。然而,JVM并没有为这些对象提供其它的信息,因此就只有留给分析分员去确定哪些是属于"JVM持有"的了ClassLoader、加载到rt.jar包中的类、异常对象(OOM )、JNI对象、所有同步对象引用、

在《深入理解Java虚拟机》一书中,我们提到以下几个对象可以用作GC根:

虚拟机堆栈中的引用对象; new的对象方法区域中的类静态属性引用的对象方法区域中的常量引用对象本地方法堆栈中的JNI引用对象的更权威的GC Root解释:1. systemclass---- classion system class loader.for everythingfromthert.jarlikejava.util.*.2.JNI local---localvariableinnnativecode, suchasuserdefinedjnicodeorjvminternalcode.3.JNI全局--- -全局可变属性代码, suchasuserdefinedjnicodeorjvminternalcode.4.threadblock------ objectreferredtofromacurrentlyactivethreadblocks任务thread.5.busy monitor-------- everythingthathascalledwait () or notify ) ) orthatissynnot bycallingsynchronized (板载ethodmeansclass,non-staticmethodmeansobject.6.Java local-------local variable.for example, inputparametersorlocallycreatedobjectsofmethodsthatarestillinthestackofathread.7.native stack------ inoroutpack可suchasuserdefinedjnicodeorjvminternalcode.thisisoftenthecaseasmanymethodshavenativepartsandtheobjectshandledasmethodparamet et eeet xample, parametersusedforfile/networki/omethodsorreflection.7.finaliza ble-------anobjectwhichisinaqueueawaitingitsfinalizertoberun.8.un finalizer a buthasnotbeenfinalizedandisnotyetonthefinalizerqueue.9.unreachable------ anobjectwhisunreachablefromanyoty bueueue jectswhichotherwisewouldnotbeincludedintheanalysis.10.javastackframe-------k frame, holdinglocalvariables.onlygeneratedwhenthedumpisparsedwiththepreferencesettotreatjavastackframesasobjects.11.unknown-- s,such as IBM便携式heap dump files, donothaverootinformation.forthesedumpsthematparsermarksobjectswhicharehavenoinboundreferencesorareunreachablefromanyotherother

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。