kotlin-examples icon indicating copy to clipboard operation
kotlin-examples copied to clipboard

Creating a primitive array produce OutOfMemoryError

Open jmetertea opened this issue 5 years ago • 0 comments

When creating a primitive array with big size as:

CharArray(99912345)

It produces Exception: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space Creates a new array of the specified size, with all elements initialized to null char (`\u0000').

Similar code in Java won't produce an exception:

char[]a = new char[99912345];

Same issue for other primitive arrays, as BooleanArray BooleanArray(99912345) Checked with Kotlin Playground

jmetertea avatar Dec 30 '19 15:12 jmetertea