Shared Constant Pool?

…衆ロ難τιáo~ 提交于 2019-12-12 21:23:13

问题


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?


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/16690815/shared-constant-pool

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!