我想知道热点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()范围时收集它。