• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package shark
2 
3 import com.github.ajalt.clikt.core.CliktCommand
4 import shark.SharkCliCommand.Companion.retrieveHeapDumpFile
5 import shark.SharkCliCommand.Companion.sharkCliParams
6 
7 class StripHprofCommand : CliktCommand(
8   name = "strip-hprof",
9   help = "Replace all primitive arrays from the provided heap dump with arrays of zeroes and generate a new \"-stripped.hprof\" file."
10 ) {
11 
runnull12   override fun run() {
13     val heapDumpFile = retrieveHeapDumpFile(context.sharkCliParams)
14     SharkLog.d { "Stripping primitive arrays in heap dump $heapDumpFile" }
15     val stripper = HprofPrimitiveArrayStripper()
16     val outputFile = stripper.stripPrimitiveArrays(heapDumpFile)
17     echo("Created hprof with stripped primitive arrays to $outputFile")
18   }
19 }