winform 关闭窗体 释放内存
来源:互联网 发布:不属于网络群众路线 编辑:程序博客网 时间:2024/05/01 18:08
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.Runtime.InteropServices;
using System.Diagnostics;
namespace ReleaseMemory_Win
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
FlushMemory();
}
[DllImport("kernel32.dll")]
private static extern bool SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
private static void FlushMemory()
{
GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
}
}
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.Runtime.InteropServices;
using System.Diagnostics;
namespace ReleaseMemory_Win
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
FlushMemory();
}
[DllImport("kernel32.dll")]
private static extern bool SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
private static void FlushMemory()
{
GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
}
}
- winform 关闭窗体 释放内存
- 关闭窗体释放内存
- winform 窗体关闭但不释放资源
- 关闭窗体不释放内存问题
- winForm 子窗体间相互切换时,关闭当前子窗体并释放资源
- WinForm窗体关闭提示
- winform关闭窗体
- Winform 多MDI窗体关闭时,无法访问已释放的对象对象名:“Icon”
- WinForm窗体禁用关闭按钮
- WinForm窗体禁用关闭按钮
- WinForm 怎样关闭登陆窗体
- c# winform窗体关闭事件
- [zz]winform 窗体关闭事件
- 【WinForm】winform中的窗体关闭方法
- winform中子窗体关闭刷新父窗体
- C#关闭窗体前释放资源
- Python关闭窗体时释放资源
- Qt关闭窗体自动释放资源
- jquery-ajax(get)调用c#后台
- 字符数字中空字符的总结
- jquery-ajax(post)调用c#后台 .
- IIS7中更改.net framework版本
- 产品可靠性
- winform 关闭窗体 释放内存
- poj1002
- jquery实现两个dropdownlist无刷新联动 .
- javascript 获取键盘、鼠标ascii码 .
- javascript(c#) 使用escape、unescape .
- Ubuntu USB Android Drivers
- [转]windchill部分表说明
- 静态内存分配和 动态内存分配
- struts2文件上传中action类中File类型的属性剖析