实现功能
自动监控特定程序,当程序占用内存超过一定阈值,转储完全dump,并间隔一定时间再次收集。这里非常感谢muzizongheng
对我的指导。
完整程序如下(使用了procdump)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace app_auto_dump
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("start...");
new AppMonitor("ConsoleTest1").Start();
}
}
class AppMonitor
{
private readonly string _appName;
private long MEMORY_1G = 1024 * 1024 * 1024;
//程序使用内存的阈值,物理内存+虚拟内存
priv