Skip to content

Instantly share code, notes, and snippets.

@rvprasad
Last active March 7, 2019 21:14
Show Gist options
  • Save rvprasad/8a4c7a45526fd696d8e6e672ceec9755 to your computer and use it in GitHub Desktop.
Save rvprasad/8a4c7a45526fd696d8e6e672ceec9755 to your computer and use it in GitHub Desktop.
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