Last active
March 7, 2019 21:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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