我得到OutOfMemoryError:java堆
该方法的片段:
{
// step 1: I am creating a 2 dim array
int totalCombination = (int) Math.pow(2.0, (double) vowelCount);
// here vowelCount > 10
// step2: initializing my array
// step3: and using that array
}
Run Code Online (Sandbox Code Playgroud)
我的问题:
每次调用此方法时,都会创建该数组.阵列是否可能未被释放.
在windows taskmanager中,我可以看到java使用的内存纯粹是增量的.因此,堆栈大小不是很小,而是重复使用内存而不是以某种方式释放.
如果您需要更多信息,请告诉我.
请帮助调试错误.
Anuj
代码中可能导致错误的部分:
int totalCombination =(int)Math.pow(2.0,(double)vowelCount);
int lookupArray[][] = new int[totalCombination][vowelCount];
// initialize lookupArray
for (int i = 0; i < totalCombination; i++) {
for (int j = 0; j < vowelCount; j++) {
lookupArray[i][j] = 0;
} …Run Code Online (Sandbox Code Playgroud)