我假设您不想分析sbt自身,因此您必须使用该fork机制并与hprof 选项结合使用:
override def fork = forkRun("-agentlib:hprof=heap=sites" :: Nil)
Run Code Online (Sandbox Code Playgroud)
或者
override def fork = Some(new ForkScalaRun {
override def runJVMOptions = super.runJVMOptions ++
Seq("-Xmx1999m", "-agentlib:hprof=heap=sites")
override def scalaJars = Seq(buildLibraryJar.asFile, buildCompilerJar.asFile)
})
Run Code Online (Sandbox Code Playgroud)
以下是一些示例选项(用于-agentlib:hprof=help获取更多帮助):
Option Name and Value Description Default
--------------------- ----------- -------
heap=dump|sites|all heap profiling all
cpu=samples|times|old CPU usage off
Run Code Online (Sandbox Code Playgroud)