Ants Memory Profiler を理解しようとしています。私が抱えている問題は、メモリリークのある簡単なアプリケーションがないことです。
Redgate (QueryBee) のサンプルを使用しましたが、私の好みに合わせたものでした。そのための簡単なアプリが必要です。
作成しようとしましたが、うまくいきません。それは機能していません。メモリリークはありません。呼び出されたフォームを破棄せずに ShowDialog を呼び出すと、メモリリークが発生することについて読みましたが、ここではそうではありません。
VS2010 と .NET 4.0 を使用しています
私は非常に一般的な問題に特に興味があります。
これが私がこれまでに持っているものです。メモリリークを取得できますか?:
メインフォーム
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MemoryLeakTest
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SubForm formToCall = new SubForm();
formToCall.ShowDialog();
}
}
}
サブフォーム
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace MemoryLeakTest
{
public partial class SubForm : Form
{
public SubForm()
{
InitializeComponent();
}
private void SubForm_Load(object sender, EventArgs e)
{
ArrayList persons = new ArrayList();
for (int i = 0; i <= 50000; i++)
{
var person = new {
Name = "1 SchorschSchorschSchorschSchorschSchorschSchorschSchorschSchorschSchorschSchorschSchorschSchorschSchorsch",
LastName = "KluniKluniKluniKluniKluniKluniKluniKluniKluniKluniKluniKluniKluniKluniKluniKluniKluniKluniKluniKluni",
Age = 50,
City = "LondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondonLondon",
Zip = "223012230122301223012230122301223012230122301223012230122301223012230122301223012230122301223012230122301223012230122301223012230122301",
Index = i
};
persons.Add(person);
}
dataGridView1.DataSource = persons;
}
private void SubForm_FormClosed(object sender, FormClosedEventArgs e)
{
//this.Dispose();
}
}
}