Java对象中的函数引用使用了多少内存? [英] How much memory is used for function references in a Java object?

查看:100
本文介绍了Java对象中的函数引用使用了多少内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是32位还是64位,取决于JVM,还是更少?因为在寻址函数时,我们真的需要这么多的地址可能性吗?

Is it 32-bit / 64-bit depending on the JVM, or is it less as do we really need that many possibilities for addresses when addressing functions?

当然,我们将永远不需要那么多的可能性作为类型的数目,并且结果函数的数目永远也不会达到这些数目?

Surely we would never need that many possibilities as the number of types, and resulting number of functions would never reach these numbers?

推荐答案

到目前为止,最简单的实现使用函数的真实"/完整地址,无论所涉及的体系结构上可能是什么(例如,函数序言的第一条指令).是的,这样的函数指针可能会很大.这是一件好事!

The by far simplest implementation uses the "real"/full address of the function, whatever that may be on the architecture in question (e.g. the virtual address of the first instruction of the function prologue). So yeah, such a function pointer will probably be a word large. And this is a good thing!

大小在任何地方都没有对象引用或对象标头重要,因为每个方法在整个过程中只有一个这样的指针,而不管有多少个实例.此外,任何用于缩小地址的方案都意味着您需要其他操作来 call 指向所指向的函数(某些间接方法或某种算法).这将是不好的,因为每次调用虚拟方法(优化之前都是所有,之后还要调用许多虚拟方法)时,都必须发生这种情况.

Size is not anywhere as important as for object references or object headers, because there is only one such pointer in the whole process per method, regardless of how many instances there are. Moreover, any scheme for shrinking the address means you need additional operations to call the function pointed to (either some indirection, or some arithmetic). That would be bad, because it has to happen every time a virtual method (which is all of them prior to optimizations, and still quite a few afterwards) is called.

这篇关于Java对象中的函数引用使用了多少内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆