Winform OpenFileDialog,每次打开,内存都会增加,dispose()和OpenFileDialog = null都不行,内存不会丢失。.
如何解决这个问题?
private void btnLocalPicture_Click(object sender, EventArgs e)
{
OpenFileDialog ofdSelectPicture = new OpenFileDialog();
ofdSelectPicture.Filter = "PicFile|*.jpg;*.png;*.jpeg;*.gif;*.bmp;*.tif";
if (ofdSelectPicture.ShowDialog() == DialogResult.OK)
{
if (showPicture != null)
showPicture.Dispose();
showPicture = Image.FromFile(ofdSelectPicture.FileName);
if (pbShowPicture.Image != null)
pbShowPicture.Image.Dispose();
pbShowPicture.Image = showPicture;
path = ofdSelectPicture.FileName;
WordTip.Visible = false;
if (pbShowPicture.Image != null)
picOK.Enabled = true;
}
ofdSelectPicture.Dispose(); //not working
ofdSelectPicture = null; //not working
GC.Collect();
}