栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

即使每个字段都是4字节对齐的,为什么Java对象中也存在内部碎片?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

即使每个字段都是4字节对齐的,为什么Java对象中也存在内部碎片?

有时,HotSpot注入内部特定于VM的字段,这些字段在Java级别不可见。在

ClassLoader
情况下,这是一个指向
ClassLoaderData

#define CLASSLOADER_INJECTED_FIELDS(macro)        macro(java_lang_ClassLoader, loader_data,  intptr_signature, false)

这是一个

intptr_t
类型的字段,即恰好8个字节长。

这是HotSpot源描述
ClassLoaderData的方式:

// A ClassLoaderData identifies the full set of class types that a class// loader's name resolution strategy produces for a given configuration of the// class loader.// Class types in the ClassLoaderData may be defined by from class file binaries// provided by the class loader, or from other class loader it interacts with// according to its name resolution strategy.//// Class loaders that implement a deterministic name resolution strategy// (including with respect to their delegation behavior), such as the boot, the// extension, and the system loaders of the JDK's built-in class loader// hierarchy, always produce the same linkset for a given configuration.//// ClassLoaderData carries information related to a linkset (e.g.,// metaspace holding its klass definitions).// The System Dictionary and related data structures (e.g., placeholder table,// loader constraints table) as well as the runtime representation of classes// only reference ClassLoaderData.//// Instances of java.lang.ClassLoader holds a pointer to a ClassLoaderData that// that represent the loader's "linking domain" in the JVM.//// The bootstrap loader (represented by NULL) also has a ClassLoaderData,// the singleton class the_null_class_loader_data().


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/454566.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号