我想知道是否存在热点JVM或任何其他JVM可以确定性地进行垃圾收集的任何实例.我知道转义分析,但想知道它是否也适用于堆分配的对象.我的意思是在C++代码中,这样可以在堆中提供确定性的垃圾收集
#include <vector>
int main(int argc, char*argv[]){
std::vector<double> v_somevector;
} // std::vector::~vector() is called determinitically
Run Code Online (Sandbox Code Playgroud)
当然在Java中就像
.
.
.
private double ma() throws Exception{
double result = 0.0;
final double[] closes = new double[100000];
//perform some calculation using the closes array above
return result;
} // At this point why shouldn't closes be deterministically garbage collected (as in immediately)?
Run Code Online (Sandbox Code Playgroud)
在收集关闭数组的垃圾中应该是确定性的.对于看起来似乎,转义分析似乎关注在堆栈上分配关闭数组的可能性,但即使在堆上分配,在这种情况下,我不明白为什么它离开ma()时无法收集范围