Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A script to identify how many longs can we store at a time with given heap size on JVM
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
object M {
def main(args: Array[String]) {
val t = new ArrayBuffer[Long]()
while (true) {
t += Random.nextLong
if (t.length % 10000 == 0) {
System.gc()
println(s"${t.length}")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment