Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,24 +239,20 @@ internal class RealHeapAnalysisJob(
checkStopAnalysis("stripping heap dump")
}

var openCalls = 0
val deletingFileSourceProvider = StreamingSourceProvider {
openCalls++
sensitiveSourceProvider.openStreamingSource().apply {
if (openCalls == 2) {
// Using the Unix trick of deleting the file as soon as all readers have opened it.
// No new readers/writers will be able to access the file, but all existing
// ones will still have access until the last one closes the file.
SharkLog.d { "Deleting $sourceHeapDumpFile eagerly" }
sourceHeapDumpFile.delete()
}
}
}

val strippedHprofSink = strippedHeapDumpFile.outputStream().sink().buffer()
val stripper = HprofPrimitiveArrayStripper()

stripper.stripPrimitiveArrays(deletingFileSourceProvider, strippedHprofSink)
stripper.stripPrimitiveArrays(
hprofSourceProvider = sensitiveSourceProvider,
hprofSink = strippedHprofSink,
onDoneOpeningNewSources = {
// Using the Unix trick of deleting the file as soon as all readers have opened it.
// No new readers/writers will be able to access the file, but all existing
// ones will still have access until the last one closes the file.
SharkLog.d { "Deleting $sourceHeapDumpFile eagerly" }
sourceHeapDumpFile.delete()
}
)
}

private fun analyzeHeapWithStats(heapDumpFile: File): Pair<HeapAnalysis, String> {
Expand Down
Loading
Loading