Excessive Memory Consumption in blank-ish WinForms application

前端 未结 1 517
臣服心动
臣服心动 2021-01-24 08:03

Why is my Windows Forms application consuming more and more memory when it\'s a blank app and not even being used by the user (me)?

You may be able to reproduce with the

相关标签:
1条回答
  • 2021-01-24 08:48

    The GC is not collecting unused memory, since it's is very small.

    You can try forcing the GC collect (not a good practice, just for testing)

    public Form1()
        {
            InitializeComponent();
            _timer.Interval = 10000;
            _timer.Tick += _timer_Tick;
            _timer.Start();
        }
    
        void _timer_Tick(object sender, EventArgs e)
        {
            GC.Collect();
        }
    

    After this the memory stays at 3.2 MB at my PC :)

    0 讨论(0)
提交回复
热议问题