art虚拟机中的gcroot

 

MAT help文档中的注释

Garbage Collection Roots

A garbage collection root is an object that is accessible from outside the heap. The following reasons make an object a GC root:

System Class

Class loaded by bootstrap/system class loader. For example, everything from the rt.jar like java.util.* .

JNI Local

Local variable in native code, such as user defined JNI code or JVM internal code.

JNI Global

Global variable in native code, such as user defined JNI code or JVM internal code.

Thread Block

Object referred to from a currently active thread block.

Thread

A started, but not stopped, thread.

Busy Monitor

Everything that has called wait() or notify() or that is synchronized. For example, by calling synchronized(Object) or by entering a synchronized method. Static method means class, non-static method means object.

Java Local

Local variable. For example, input parameters or locally created objects of methods that are still in the stack of a thread.

Native Stack

In or out parameters in native code, such as user defined JNI code or JVM internal code. This is often the case as many methods have native parts and the objects handled as method parameters become GC roots. For example, parameters used for file/network I/O methods or reflection.

Finalizable

An object which is in a queue awaiting its finalizer to be run.

Unfinalized

An object which has a finalize method, but has not been finalized and is not yet on the finalizer queue.

Unreachable

An object which is unreachable from any other root, but has been marked as a root by MAT to retain objects which otherwise would not be included in the analysis.

Java Stack Frame

A Java stack frame, holding local variables. Only generated when the dump is parsed with the preference set to treat Java stack frames as objects.

art虚拟机中的gcroot枚举

enum RootType {

kRootUnknown = 0,

kRootJNIGlobal,//env->newGlobalRef

kRootJNILocal,  //env->newlocalRef

kRootJavaFrame, //java栈帧

kRootNativeStack,

kRootStickyClass,

kRootThreadBlock,

kRootMonitorUsed,

kRootThreadObject, //线程对象本身,对应java Thread对象

kRootInternedString,

kRootFinalizing, // used for HPROF's conversion to HprofHeapTag

kRootDebugger,

kRootReferenceCleanup, // used for HPROF's conversion to HprofHeapTag

kRootVMInternal,

kRootJNIMonitor, //线程锁

};

怎么扫描gcroot的

art虚拟机中cc(concurren_copying)算法会把gcroot拷贝到regionspace的tospace类型的region中,

Thread相关的gcroot

1.kRootThreadObject 线程对象本身

2.kRootJNILocal,即通过newlocalRef添加到localRefenceTable中的java obj

在​​​​​​FlipThreadRoots 方法中会调用

void Thread::VisitRoots(RootVisitor* visitor) {const uint32_t thread_id = GetThreadId();visitor->VisitRootIfNonNull(&tlsPtr_.opeer, RootInfo(kRootThreadObject, thread_id));if (tlsPtr_.exception != nullptr && tlsPtr_.exception != GetDeoptimizationException()) {visitor->VisitRoot(reinterpret_cast<mirror::Object**>(&tlsPtr_.exception),RootInfo(kRootNativeStack, thread_id));}if (tlsPtr_.async_exception != nullptr) {visitor->VisitRoot(reinterpret_cast<mirror::Object**>(&tlsPtr_.async_exception),RootInfo(kRootNativeStack, thread_id));}visitor->VisitRootIfNonNull(&tlsPtr_.monitor_enter_object, RootInfo(kRootNativeStack, thread_id));tlsPtr_.jni_env->VisitJniLocalRoots(visitor, RootInfo(kRootJNILocal, thread_id));tlsPtr_.jni_env->VisitMonitorRoots(visitor, RootInfo(kRootJNIMonitor, thread_id));HandleScopeVisitRoots(visitor, thread_id);// Visit roots for deoptimization.if (tlsPtr_.stacked_shadow_frame_record != nullptr) {RootCallbackVisitor visitor_to_callback(visitor, thread_id);ReferenceMapVisitor<RootCallbackVisitor, kPrecise> mapper(this, nullptr, visitor_to_callback);for (StackedShadowFrameRecord* record = tlsPtr_.stacked_shadow_frame_record;record != nullptr;record = record->GetLink()) {for (ShadowFrame* shadow_frame = record->GetShadowFrame();shadow_frame != nullptr;shadow_frame = shadow_frame->GetLink()) {mapper.VisitShadowFrame(shadow_frame);}}}for (DeoptimizationContextRecord* record = tlsPtr_.deoptimization_context_stack;record != nullptr;record = record->GetLink()) {if (record->IsReference()) {visitor->VisitRootIfNonNull(record->GetReturnValueAsGCRoot(),RootInfo(kRootThreadObject, thread_id));}visitor->VisitRootIfNonNull(record->GetPendingExceptionAsGCRoot(),RootInfo(kRootThreadObject, thread_id));}if (tlsPtr_.frame_id_to_shadow_frame != nullptr) {RootCallbackVisitor visitor_to_callback(visitor, thread_id);ReferenceMapVisitor<RootCallbackVisitor, kPrecise> mapper(this, nullptr, visitor_to_callback);for (FrameIdToShadowFrame* record = tlsPtr_.frame_id_to_shadow_frame;record != nullptr;record = record->GetNext()) {mapper.VisitShadowFrame(record->GetShadowFrame());}}// Visit roots on this thread's stackRuntimeContextType context;RootCallbackVisitor visitor_to_callback(visitor, thread_id);ReferenceMapVisitor<RootCallbackVisitor, kPrecise> mapper(this, &context, visitor_to_callback);mapper.template WalkStack<StackVisitor::CountTransitions::kNo>(false);
}

全局的gcroot

void Runtime::VisitNonThreadRoots(RootVisitor* visitor) {java_vm_->VisitRoots(visitor); //kRootGlobalsentinel_.VisitRootIfNonNull(visitor, RootInfo(kRootVMInternal));pre_allocated_OutOfMemoryError_when_throwing_exception_.VisitRootIfNonNull(visitor, RootInfo(kRootVMInternal));pre_allocated_OutOfMemoryError_when_throwing_oome_.VisitRootIfNonNull(visitor, RootInfo(kRootVMInternal));pre_allocated_OutOfMemoryError_when_handling_stack_overflow_.VisitRootIfNonNull(visitor, RootInfo(kRootVMInternal));pre_allocated_NoClassDefFoundError_.VisitRootIfNonNull(visitor, RootInfo(kRootVMInternal));VisitImageRoots(visitor);class_linker_->VisitTransactionRoots(visitor);
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/882094.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C++之设计原则

在C中&#xff0c;设计原则是一套指导软件开发过程中决策和设计模式的准则&#xff0c;旨在提高软件的可维护性、可扩展性、灵活性和可靠性。 以下是几种核心设计原则&#xff1a; 1.单一职责 功能单一&#xff0c;方便组合和复用。 图示&#xff1a; 应用场景&#xff1a;…

【godot游戏引擎学习笔记】初识界面

个人笔记&#xff0c;学习自B站视频BV1ut42177r8 目录 渲染器的选择 Forward 移动 兼容 编辑器页面 浏览场景&#xff08;左上角&#xff09; 文件浏览器&#xff08;左下角&#xff09; 属性检查器&#xff08;右侧&#xff09; 场景编辑器&#xff08;中间&#x…

electron本地OCR实现

使用tesseract.js - npm (npmjs.com) 官方demo&#xff1a;GitHub - Balearica/tesseract.js-electron: An example to use tesseract.js in electron 目录结构&#xff1a; // 引入 <script type"module" src"./ocr/tesseract.js"></script>…

如何设置 GitLab 密码过期时间?

GitLab 是一个全球知名的一体化 DevOps 平台&#xff0c;很多人都通过私有化部署 GitLab 来进行源代码托管。极狐GitLab 是 GitLab 在中国的发行版&#xff0c;专门为中国程序员服务。可以一键式部署极狐GitLab。 学习极狐GitLab 的相关资料&#xff1a; 极狐GitLab 60天专业…

Go-知识反射

Go-知识反射 1. 接口1.1 类型1.2 interface 类型1.2.1 interface 变量1.2.2 实现接口1.2.3 复合类型1.2.4 空 interface 2. 反射定律2.1 reflect 包2.2 反射可以将 interface 类型变量转换为反射对象2.3 反射可以将反射对象还原成 interface 对象2.4 反射对象可修改&#xff0c…

Oracle权限安全管理

实验内容 本次实验先使用system用户连接 温馨提示&#xff1a;题目要求切换账户登录的时候自己记得切换&#xff0c;本文章只提供相应的SQL语句 在表空间BOOKTBS1&#xff08;实验4第1题已创建&#xff09;创建一张表BOOKS,其字段如下&#xff1a;&#xff1a; SQL> create…

一次性语音芯片:重塑语音识别技术,引领智能化生活新时代

随着一次性语音芯片的突破性进展&#xff0c;语音识别技术正融入我们生活的方方面面&#xff0c;引领着智能化生活迈向一个全新的时代。这些芯片不仅体积小巧、成本低廉&#xff0c;更在性能上实现了质的飞跃&#xff0c;能够更精确地捕捉并理解人类语音。本文将解读关于一次性…

嵌入式开发选硬件还是软件?

做了单片机软件开发很多年&#xff0c;和很多硬件工程师打过配合&#xff0c;其中大部分硬件工程师&#xff0c;越往后&#xff0c;学软件的意愿越强烈。 所以我建议是&#xff0c;先做软件&#xff0c;是比较好的发育路线。 软件开发的优势主要体现在几个方面。 第一是薪资待遇…

python爬虫实战案例——从移动端接口抓取微博评论,采用cookie登陆,数据存入excel表格,超详细(15)

文章目录 1、任务目标2、网页分析3、代码编写3.1 代码分析3.2 完整代码1、任务目标 1、目标网站:微博文章(https://m.weibo.cn/detail/4813628149072458),这是微博某一篇博文,用于本文测试 2、要求:爬取该博文下,所有一级评论和二级评论,以及每条评论的作者,最后保存至E…

Python魔法函数__iter__的用法

下面是找到的一个比较好的科学解释&#xff1a; Python中可迭代对象(Iterable)并不是指某种具体的数据类型&#xff0c;它是指存储了元素的一个容器对象&#xff0c;且容器中的元素可以通过__iter__( )方法或__getitem__( )方法访问。 1.__iter__方法的作用是让对象可以用for…

Vscode替换\n为换行符

文件内容是字符串&#xff0c;每行用\n分割&#xff0c;阅读困难&#xff0c;可以在vscode&#xff0c;用替换\n进行换行。

120多套各种类别微信小程序模板源码

微信小程序是一种轻量级的应用开发平台&#xff0c;由腾讯公司推出&#xff0c;主要应用于移动端&#xff0c;为用户提供便捷的服务体验。本资源包含120套微信小程序的源码&#xff0c;对于开发者来说是一份宝贵的参考资料&#xff0c;可以用来学习、研究或者作为开发新项目的起…

【Linux系统编程】环境基础开发工具使用

目录 1、Linux软件包管理器yum 1.1 什么是软件包 1.2 安装软件 1.3 查看软件包 1.4 卸载软件 2、Linux编辑器-vim 2.1 vim的概念 2.2 vim的基本操作 2.3 vim的配置 3、Linux编译器-gcc/g 3.1 gcc编译的过程​编辑​编辑​编辑 3.2 详解链接 动态链接 静态链接 4…

C++【内存管理】(超详细讲解C++内存管理以及new与delete的使用和原理)

文章目录 1.C/C内存分布2.C语言中动态内存管理方式3.C内存管理方式3.1 new/delete操作内置类型3. 2new/delete操作自定义类型 4. operator new与operator delete函数&#xff08;重点&#xff09;5. new和delete的实现原理5.1 内置类型5.2 自定义类型5.2.1 自定义类型调用new[]…

JAVA就业笔记6——第二阶段(3)

课程须知 A类知识&#xff1a;工作和面试常用&#xff0c;代码必须要手敲&#xff0c;需要掌握。 B类知识&#xff1a;面试会问道&#xff0c;工作不常用&#xff0c;代码不需要手敲&#xff0c;理解能正确表达即可。 C类知识&#xff1a;工作和面试不常用&#xff0c;代码不…

Python 如何处理大规模数据库表的迁移与数据迁移的高效执行

Python 如何处理大规模数据库表的迁移与数据迁移的高效执行 引言 在现代应用开发中&#xff0c;随着业务需求的增长&#xff0c;数据库表结构和数据往往需要进行迁移和更新。迁移&#xff08;Migration&#xff09;是指对数据库表的结构、数据类型、索引、约束等进行修改或更新…

电脑桌面便签怎么添加,好用便签软件怎么样?

在数字化时代&#xff0c;电脑桌面便签是现代工作和学习中不可或缺的工具&#xff0c;它能够帮助用户记录重要信息、设置提醒事项并高效管理任务。那么&#xff0c;电脑桌面便签怎么添加&#xff0c;好用便签软件怎么样呢&#xff1f;接下来让我们一起来探讨下吧。 一&#xf…

13.3寸工业三防平板数字化工厂产线数采手持终端

在数字化工厂的建设浪潮中&#xff0c;高效可靠的数据采集终端至关重要。尤其在水处理、食品加工等特殊工业环境下&#xff0c;设备的耐用性和数据安全性面临严峻挑战。传统的平板电脑难以应对复杂的工业现场&#xff0c;而一款性能卓越、坚固耐用的工业三防平板则成为提升生产…

使用docker搭建lnmp运行WordPress

一&#xff0c;部署目的 使用 Docker 技术在单机上部署 LNMP 服务&#xff08;Linux Nginx MySQL PHP&#xff09;。部署并运行 WordPress 网站平台。掌握 Docker 容器间的互联及数据卷共享。 二&#xff0c;部署环境 操作系统&#xff1a;CentOS 7Docker 版本&#xff1…

路由通信 的 VLAN技术

一、VLAN基础 虚拟局域网&#xff08;Virtual Local Area Network&#xff0c;VLAN&#xff09; 根据管理功能、组织机构或应用类型对交换局域网进行分段而形成的逻辑网络。 交换机最多支持4094个VLAN&#xff0c;其中默认管理VLAN是VLAN1&#xff0c;不能创建&#xff0c;也…