我的应用程序是用Play 2.4.6(Scala)编写的。当应用程序部署在生产环境中时,它需要大约1.4 GB的内存(捕获的RSS顶部)。
服务的堆使用量大约为2.5 GB,然后下降到500 MB。最初我怀疑内存泄漏但是堆在一段时间后被清除。
然而,即使堆使用减少,应用程序使用的剩余内存也没有变化。应用程序的剩余内存使用量不断增长。
我无法理解这里出了什么问题。这与某些配置(java内存参数)或我的代码是否导致此问题有关?如何避免剩余内存使用量的增长?
运行应用程序时的堆参数:-J-Xms2G -J-Xmx8G
注意:我使用的是scala 2.11.8,Java 8和Akka 2.4.4。
build.sbt
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
ws,
"com.datastax.cassandra" % "cassandra-driver-core" % "2.0.12",
"net.databinder.dispatch" %% "dispatch-core" % "0.11.2",
"org.apache.shiro" % "shiro-core" % "1.2.2",
"org.apache.shiro" % "shiro-ehcache" % "1.2.2",
"com.typesafe.akka" %% "akka-actor" % "2.4.4",
"com.typesafe.akka" %% "akka-slf4j" % "2.4.4",
"com.typesafe.akka" %% "akka-contrib" % "2.4.4",
"com.typesafe.akka" %% "akka-cluster" % "2.4.4",
"com.tuplejump.utils" %% "xformer" % "0.0.1"
)
resolvers ++= Seq(
"sgodbillon" at "bitbucket.org/sgodbillon/repository/raw/master/snapshots/",
"terracotta" at "terracotta.org/download/reflector/releases";
)
plugins.sbt
resolvers += "Typesafe repository" at "repo.typesafe.com/typesafe/releases/";
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.6")