共享常量池? [英] Shared Constant Pool?
问题描述
与Java虚拟机相比,Dalvik虚拟机获得共享常量池"是什么意思?
What does it mean when the Dalvik Virtual Machine got a "Shared Constant Pool" compared to the Java Virtual Machine?
这有什么好处?达尔维克机器如何实现这一目标?
How is this a benefit and how does the Dalvik Machine achieve this?
推荐答案
Java虚拟机将每个类存储在一个单独的.class文件中.每个类文件都有一个常量池,用于存储诸如字符串,方法名,类名等之类的内容.如果多个类引用相同的字符串,则每个类文件将在其常量池中具有该字符串的副本.
The Java virtual machine stores each class in an individual .class file. Each class file has a constant pool for things like strings, method names, class names, etc. If multiple classes reference the same string, then each class file will have a copy of that string in its constant pool.
Dalvik虚拟机将多个类存储在单个dex文件中,并具有单个常量池.因此,如果多个类引用相同的字符串,则该dex文件的全局"常量池中将只有该字符串的一个副本.
The Dalvik virtual machine stores multiple classes in a single dex file, with a single constant pool. So if multiple classes reference the same string, there will only be one copy of that string in the "global" constant pool for that dex file.
好处是它具有更高的空间利用率,并且由于dalvik内存将这些dex文件映射到内存中,因此它也具有更高的内存效率.
The benefit is that it is more space efficient, and since dalvik memory maps these dex files into memory, it is also more memory efficient.
这篇关于共享常量池?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!