How to Fix the Memory Leak in IE WebBrowser Control?

后端 未结 18 968
走了就别回头了
走了就别回头了 2020-11-27 05:33

I am trying to embed a WebBrowser Control in a C# Winform Application. This sounds easy enough. However I discovered that the WebBrowser control eats up a lot of memory ever

18条回答
  •  广开言路
    2020-11-27 05:53

    The BASIC IDEA is,

    "Kill myself, and reborn."

    Windows will solve all memory problems.

    but if you Close your application first, you can't start a new one.

    So, START A NEW ONE, and CLOSE THE OLDER ONE.

    First turn on a new one, and turn off an old one.


    public void SOLVE_ALL_MY_MEMORY_PROBLEM()
    {
      System.Diagnostics.Process.Start("MyProgram.exe");
      Application.Exit();
    }
    

    https://www.youtube.com/watch?v=aTBlKRzNf74

    If there is a parameter,

    public void SOLVE_ALL_MY_MEMORY_PROBLEM()
    {
      System.Diagnostics.Process.Start("MyProgram.exe", "PARA_para_dance");
      Application.Exit();
    }
    

    Go to Program.cs

        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if(args.Count() > 0)
                Application.Run(new Form1(args[0]));
            else
                Application.Run(new Form1());
        }
    

    and, Go to Form1.cs and make another Form1()

        public Form1()
        {
            InitializeComponent();
        }
    
        public Form1(string dance_name)
        {
            InitializeComponent();
    
            ...
        }
    

    or you can use temp file !!!

提交回复
热议问题