8062490: Out of memory problems, as untouched array datas didn't go directly to SparseArrayDatas, but dragged very large int arrays around
Reviewed-by: attila, sundar
This commit is contained in:
parent
75d37c8e9c
commit
d82a461e44
@ -98,6 +98,10 @@ public abstract class ArrayData {
|
||||
@Override
|
||||
public ArrayData ensure(final long safeIndex) {
|
||||
if (safeIndex > 0L) {
|
||||
if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH) {
|
||||
return new SparseArrayData(this, safeIndex + 1);
|
||||
}
|
||||
//known to fit in int
|
||||
return toRealArrayData((int)safeIndex).ensure(safeIndex);
|
||||
}
|
||||
return this;
|
||||
|
@ -38,6 +38,11 @@ import jdk.nashorn.internal.runtime.ScriptRuntime;
|
||||
class SparseArrayData extends ArrayData {
|
||||
static final long MAX_DENSE_LENGTH = 16 * 512 * 1024;
|
||||
|
||||
static {
|
||||
// we must break into sparse arrays before we require long indexes
|
||||
assert MAX_DENSE_LENGTH <= Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
/** Underlying array. */
|
||||
private ArrayData underlying;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user