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

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

即使每个字段都是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().


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5430092.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存