fork download
  1. public partial class Form1 : Form
  2. {
  3. public Form1()
  4. {
  5. InitializeComponent();
  6. }
  7.  
  8. private void Form1_Shown(object sender, EventArgs e)
  9. {
  10. int count = 80;
  11.  
  12. DataGridViewColumn[] cols = new DataGridViewColumn[count];
  13.  
  14. for (int i = 0; i < count; ++i)
  15. {
  16. cols[i] = new DataGridViewTextBoxColumn();
  17. }
  18.  
  19. dataGridView1.Columns.AddRange(cols);
  20. }
  21.  
  22. private void button1_Click(object sender, EventArgs e)
  23. {
  24. memoryLeakTest();
  25. }
  26.  
  27. private void memoryLeakTest()
  28. {
  29. //してもしなくても変わらなかったのでコメント化
  30. //foreach (DataGridViewRow row in dataGridView1.Rows)
  31. //{
  32. // row.Dispose();
  33. //}
  34.  
  35. dataGridView1.Rows.Clear();
  36.  
  37. int dataCount = 300;
  38.  
  39. int colCount = dataGridView1.Columns.Count;
  40.  
  41. DataGridViewRow[] rows = new DataGridViewRow[dataCount];
  42.  
  43. for (int i = 0; i < dataCount; ++i)
  44. {
  45. DataGridViewRow row = new DataGridViewRow();
  46. row.CreateCells(dataGridView1);
  47.  
  48. for (int j = 0; j < colCount; ++j)
  49. {
  50. row.Cells[j].Value = $"{i}の{j}";
  51. }
  52.  
  53. rows[i] = row;
  54. }
  55.  
  56. dataGridView1.Rows.AddRange(rows);
  57. }
  58. }
  59.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class, interface, or enum expected
    public partial class Form1 : Form
           ^
Main.java:1: error: '{' expected
    public partial class Form1 : Form
                              ^
Main.java:50: error: ';' expected
                    row.Cells[j].Value = $"{i}?{j}";
                                          ^
3 errors
stdout
Standard output is empty