我想知道是否存在热点 JVM 或任何其他 JVM 可以确定性地进行垃圾收集的任何实例。我知道逃逸分析,但想知道它是否也适用于堆分配的对象。我的意思是在这样的 C++ 代码中,可以从堆中进行确定性垃圾收集
#include <vector>
int main(int argc, char*argv[]){
std::vector<double> v_somevector;
} // std::vector::~vector() is called determinitically
当然在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)?
在垃圾收集关闭数组时应该是确定性的。看起来,逃逸分析似乎专注于在堆栈上分配关闭数组的可能性,但即使在堆上分配,在这种情况下,我不明白为什么在离开 ma()' 时无法收集它范围