当前位置:网站首页>JVM runtime constant pool and direct memory

JVM runtime constant pool and direct memory

2022-06-11 21:05:00 Just number six Z

Runtime constant pool

The runtime constant pool is part of the method area .Class Except for the version of the class in the file 、 Field 、 Method 、 Interface and other description information , And the constant pool table .

Constant pool

A valid bytecode file contains the version information of the class 、 Field 、 Methods and interfaces , Also included is the constant pool , Contains a variety of literal quantities and pairs of types 、 Symbolic references to fields and methods .

Why constant pools are needed ?

One java Classes in the source file 、 Interface , After compiling, a bytecode file is generated . and Java The bytecode in needs data support , Usually this data is too large to be stored directly in bytecode , Another way , It can be stored in a constant pool , This bytecode contains a reference to the constant pool . The runtime constant pool is used in dynamic linking .

Data types stored in the constant pool

  • Quantity is worth
  • A string value
  • Class reference
  • Field reference
  • Method reference

Runtime constant pool

  • Runtime constant pool (Runtime Constant Pool) Is part of the method area .
  • Constant pool table (Constant Pool Table) yes Class Part of the document , Used to store various literal quantities and symbol references generated by the compiler , This part will be stored in the runtime constant pool of the method area after the class is loaded .
  • Runtime constant pool , be relative to Class Another important feature of the file constant pool is : dynamic .

Direct memory

Direct memory is not part of the VM runtime data area , It's not the memory area defined in the virtual machine specification , But this part of memory is also frequently used . And it can also lead to OutOfMemoryError Error occurred .

Direct memory allocation is not affected by Java Pile limits , however , Since memory is limited by the total memory size of the machine and the addressing space of the processor .

Direct memory is Java Out of the pile 、 Memory range directly applied to the system . Access to direct memory is faster than Java Pile up , That is to say, the read-write performance is high .

原网站

版权声明
本文为[Just number six Z]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206112054044160.html