After a single run of RandomMapGenerator the reported retained size by the Map is ~1.6GiB. YourKit profiler was used.
Last active
July 25, 2017 10:25
-
-
Save maciej/18bee77cf53c530e376f472ba1a20f7c to your computer and use it in GitHub Desktop.
HPPC LongIntMap memory usage
This file contains hidden or 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
name := "map-sizes" | |
version := "1.0" | |
scalaVersion := "2.12.2" | |
libraryDependencies += "com.carrotsearch" % "hppc" % "0.7.2" |
This file contains hidden or 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 com.carrotsearch.hppc.LongIntHashMap | |
import scala.util.Random | |
object RandomMapGenerator { | |
private[this] val random = new Random() | |
private val ElementsToGenerate = 100 * 1000 * 1000 | |
def main(args: Array[String]): Unit = { | |
val map = new LongIntHashMap() | |
for (i <- 0 until ElementsToGenerate) { | |
val key = random.nextLong() | |
val value = random.nextInt() | |
map.put(key, value) | |
} | |
println(s"Map generated, feel free to dump the heap. Key distribution is: ${map.visualizeKeyDistribution(8)}.") | |
// Wait | |
Console.in.readLine() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment