public void Execute(CommandExecutionContext context)
{
if (!InMemoryOnly)
{
if (context.TargetType == TargetType.LiveProcess)
{
context.WriteErrorLine(
"Generating a persistent heap index for a live process is not recommended. " +
"Use the --nofile switch to generate an in-memory index instead.");
return;
}
if (String.IsNullOrEmpty(HeapIndexFileName))
{
HeapIndexFileName = Path.ChangeExtension(context.DumpFile, ".heapindex");
context.WriteLine("Using an automatically generated heap index filename: '{0}'", HeapIndexFileName);
}
}
if (InMemoryOnly && !String.IsNullOrEmpty(HeapIndexFileName))
{
context.WriteErrorLine("The --nofile and -f options are incompatible.");
return;
}
// If the index fails to build, clear it so that other commands know we don't have an index.
context.HeapIndex = new HeapIndex(context);
if (!context.HeapIndex.Build(ChunkSize, InMemoryOnly ? null : HeapIndexFileName, !EnumerateRootsFast))
context.HeapIndex = null;
}