Click here to Skip to main content
15,888,521 members
Home / Discussions / C#
   

C#

 
GeneralRe: printer default font. Pin
OriginalGriff7-Jul-17 4:30
mveOriginalGriff7-Jul-17 4:30 
GeneralRe: printer default font. Pin
Richard MacCutchan7-Jul-17 5:19
mveRichard MacCutchan7-Jul-17 5:19 
AnswerRe: printer default font. Pin
Richard Andrew x647-Jul-17 7:41
professionalRichard Andrew x647-Jul-17 7:41 
GeneralRe: printer default font. Pin
rahul19959-Jul-17 18:48
rahul19959-Jul-17 18:48 
AnswerRe: printer default font. Pin
jschell10-Jul-17 4:39
jschell10-Jul-17 4:39 
GeneralRe: printer default font. Pin
rahul199510-Jul-17 19:02
rahul199510-Jul-17 19:02 
GeneralRe: printer default font. Pin
Dave Kreskowiak11-Jul-17 3:30
mveDave Kreskowiak11-Jul-17 3:30 
Questionusing Form does not release memory Pin
Montgomery-Burns6-Jul-17 22:12
Montgomery-Burns6-Jul-17 22:12 
In Microsoft Visual Studio Enterprise 2015 I have created the simplest Windows Forms Application (.NET Framework 4.5.2.):

On the main Form1 there's a button1. When you press it the Form2 opens and closes immediately and loops with this Form2 open and closure.

On Windows 10 Task Manager you will see the memory usage increasing . I expect the memory to be released instead . Obviously after some time the memory usage will be huge and cause problems.

It's a test that anyone can do. How can this be possible? Even if I decrease the loop and wait for the cycle to finish, the memory is not released.


C#
  public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int loop = 100000;

            for (int i = 0; i < loop; i++)
            {
                using (Form2 a = new Form2())
                {
                    a.ShowDialog(this);
                }

                // Uncommenting the 2 following lines doesn't make any difference
                // GC.Collect();
                // GC.WaitForPendingFinalizers();
            }
        }
    }

    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            Close();
        }
    }
Mr. Burns

Montgomery Burns

AnswerRe: using Form does not release memory Pin
OriginalGriff6-Jul-17 23:59
mveOriginalGriff6-Jul-17 23:59 
GeneralRe: using Form does not release memory Pin
Montgomery-Burns7-Jul-17 0:15
Montgomery-Burns7-Jul-17 0:15 
GeneralRe: using Form does not release memory Pin
OriginalGriff7-Jul-17 0:31
mveOriginalGriff7-Jul-17 0:31 
GeneralRe: using Form does not release memory Pin
Montgomery-Burns7-Jul-17 2:40
Montgomery-Burns7-Jul-17 2:40 
GeneralRe: using Form does not release memory Pin
Dave Kreskowiak7-Jul-17 2:31
mveDave Kreskowiak7-Jul-17 2:31 
GeneralRe: using Form does not release memory Pin
OriginalGriff7-Jul-17 2:42
mveOriginalGriff7-Jul-17 2:42 
GeneralRe: using Form does not release memory Pin
Dave Kreskowiak7-Jul-17 7:34
mveDave Kreskowiak7-Jul-17 7:34 
GeneralRe: using Form does not release memory Pin
OriginalGriff7-Jul-17 7:58
mveOriginalGriff7-Jul-17 7:58 
AnswerRe: using Form does not release memory Pin
Dave Kreskowiak7-Jul-17 2:29
mveDave Kreskowiak7-Jul-17 2:29 
GeneralRe: using Form does not release memory Pin
Richard Andrew x647-Jul-17 7:28
professionalRichard Andrew x647-Jul-17 7:28 
GeneralRe: using Form does not release memory Pin
Dave Kreskowiak7-Jul-17 7:34
mveDave Kreskowiak7-Jul-17 7:34 
GeneralRe: using Form does not release memory Pin
Montgomery-Burns10-Jul-17 20:23
Montgomery-Burns10-Jul-17 20:23 
QuestionRegex: change groups value Pin
Member 102846646-Jul-17 21:51
Member 102846646-Jul-17 21:51 
AnswerRe: Regex: change groups value Pin
Richard Deeming7-Jul-17 0:42
mveRichard Deeming7-Jul-17 0:42 
QuestionNeed Help Desperately! Development server trying to find local server path Pin
BigLitz6-Jul-17 3:57
BigLitz6-Jul-17 3:57 
AnswerRe: Need Help Desperately! Development server trying to find local server path Pin
OriginalGriff6-Jul-17 5:32
mveOriginalGriff6-Jul-17 5:32 
GeneralRe: Need Help Desperately! Development server trying to find local server path Pin
BigLitz6-Jul-17 5:59
BigLitz6-Jul-17 5:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.