배열의 기본 용량은 2의 제곱 수 (2^30으로 제한됨) 여야합니다.이 크기에 도달하면로드 요소가 효과적으로 무시되고 배열의 성장이 멈 춥니 다.
이 시점에서 충돌 속도가 증가합니다.
hashCode()가 32 비트 만 가지고 있다고 가정하면 어떤 경우이든 크게 커질 수는 없습니다.
/**
* Rehashes the contents of this map into a new array with a
* larger capacity. This method is called automatically when the
* number of keys in this map reaches its threshold.
*
* If current capacity is MAXIMUM_CAPACITY, this method does not
* resize the map, but sets threshold to Integer.MAX_VALUE.
* This has the effect of preventing future calls.
*
* @param newCapacity the new capacity, MUST be a power of two;
* must be greater than current capacity unless current
* capacity is MAXIMUM_CAPACITY (in which case value
* is irrelevant).
*/
void resize(int newCapacity) {
Entry[] oldTable = table;
int oldCapacity = oldTable.length;
if (oldCapacity == MAXIMUM_CAPACITY) {
threshold = Integer.MAX_VALUE;
return;
}
Entry[] newTable = new Entry[newCapacity];
transfer(newTable);
table = newTable;
threshold = (int)(newCapacity * loadFactor);
}
크기가 Integer.MAX_VALUE를 초과하면 오버플로됩니다.
void addEntry(int hash, K key, V value, int bucketIndex) {
Entry<K,V> e = table[bucketIndex];
table[bucketIndex] = new Entry<K,V>(hash, key, value, e);
if (size++ >= threshold)
resize(2 * table.length);
}
MapOverflow.com의 속임수 –
16GB RAM이 필요하지 않습니다. 64 비트 버전의 Windows를 구하고 테스트 할 나머지 부분을위한 페이지 파일을 만드십시오. – Mehrdad
내 Windows도 32 비트입니다 :( – Bhushan